(t *testing.T)
| 84 | } |
| 85 | |
| 86 | func TestRoundTrip(t *testing.T) { |
| 87 | m := testStore(t) |
| 88 | sc := SimpleColumn{true /* deterministic */} |
| 89 | var buf bytes.Buffer |
| 90 | if err := sc.WriteTo(m, &buf); err != nil { |
| 91 | t.Fatal(err) |
| 92 | } |
| 93 | |
| 94 | n := NewSimpleInMemoryStore() |
| 95 | if err := sc.ReadInto(bytes.NewReader(buf.Bytes()), n); err != nil { |
| 96 | t.Fatal(err) |
| 97 | } |
| 98 | if n.EstimateFactCount() != m.EstimateFactCount() { |
| 99 | t.Fatalf("fact count %d want %d", n.EstimateFactCount(), m.EstimateFactCount()) |
| 100 | } |
| 101 | for _, p := range m.ListPredicates() { |
| 102 | m.GetFacts(ast.NewQuery(p), func(fact ast.Atom) error { |
| 103 | if !n.Contains(fact) { |
| 104 | t.Errorf("missing fact: %s", fact.String()) |
| 105 | } |
| 106 | return nil |
| 107 | }) |
| 108 | } |
| 109 | for _, p := range n.ListPredicates() { |
| 110 | n.GetFacts(ast.NewQuery(p), func(fact ast.Atom) error { |
| 111 | if !m.Contains(fact) { |
| 112 | t.Errorf("extra fact: %s", fact.String()) |
| 113 | } |
| 114 | return nil |
| 115 | }) |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | func TestStore(t *testing.T) { |
| 120 | m := testStore(t) |
nothing calls this directly
no test coverage detected