-
Notifications
You must be signed in to change notification settings - Fork 0
/
BasicCommands_test.go
46 lines (37 loc) · 944 Bytes
/
BasicCommands_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"testing"
)
func TestBasicInsertion(t *testing.T) {
buffer := newInputBuffer()
table := newTable()
buffer.buffer = "insert 1 csstack [email protected]"
statement := &Statement{}
switch prepareStatement(buffer, statement) {
case PREPARE_SUCCESS:
break
default:
t.Fatalf("Preparing statement for insertion failed: '%s'\n", buffer.buffer)
}
switch executeStatement(statement, table) {
case EXECUTE_SUCCESS:
break
default:
t.Fatalf("Insertion test failed for this: '%s'\n", buffer.buffer)
}
// check if it is in the table
buffer.buffer = "select"
statement = &Statement{}
switch prepareStatement(buffer, statement) {
case PREPARE_SUCCESS:
break
default:
t.Fatalf("Preparing statement for selection failed in TestBasicInsertion.")
}
switch executeStatement(statement, table) {
case EXECUTE_SUCCESS:
break
default:
t.Fatalf("Selection test failed for this: '%s'\n", buffer.buffer)
}
}