MCPcopy
hub / github.com/google/mangle / TestRoundTrip

Function TestRoundTrip

factstore/simplecolumn_test.go:86–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

84}
85
86func 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
119func TestStore(t *testing.T) {
120 m := testStore(t)

Callers

nothing calls this directly

Calls 14

WriteToMethod · 0.95
ReadIntoMethod · 0.95
EstimateFactCountMethod · 0.95
ContainsMethod · 0.95
ListPredicatesMethod · 0.95
GetFactsMethod · 0.95
NewQueryFunction · 0.92
testStoreFunction · 0.85
NewSimpleInMemoryStoreFunction · 0.85
EstimateFactCountMethod · 0.65
ListPredicatesMethod · 0.65
GetFactsMethod · 0.65

Tested by

no test coverage detected