-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,38 @@ | ||
package gotupolis | ||
|
||
import ( | ||
"testing" | ||
|
||
option "github.com/micutio/goptional" | ||
) | ||
|
||
func TestStore(t *testing.T) { | ||
store := getStoreImpl() | ||
tup := MakeTuple(I(1), I(2), F(3.14), S("Foo!"), T(MakeTuple(S("hurz")))) | ||
|
||
// test insertion | ||
store.Out(tup) | ||
|
||
// test read | ||
var tupleOpt1 option.Maybe[Tuple] = store.Read(tup) | ||
if !tupleOpt1.IsPresent() { | ||
t.Errorf("Error: cannot find inserted tuple %v", tup) | ||
} | ||
|
||
// test out | ||
// since we've only read the tuple, it should still be in the store | ||
var tupleOpt2 option.Maybe[Tuple] = store.In(tup) | ||
if !tupleOpt2.IsPresent() { | ||
t.Errorf("Error: cannot find inserted tuple %v", tup) | ||
} | ||
|
||
// now the tuple should be gone | ||
var tupleOpt3 option.Maybe[Tuple] = store.In(tup) | ||
if tupleOpt3.IsPresent() { | ||
t.Errorf("Error: store should not contain tuple %v anymore", tup) | ||
} | ||
} | ||
|
||
func getStoreImpl() Store { | ||
return NewSimpleStore() | ||
} |