package main

import "testing"

func TestGraphAccumulatorDeduplicatesEdges(t *testing.T) {
	preds := NewPredicateDict([]string{"http://example.com/p"})
	acc := newGraphAccumulator(16, false, 16, preds)

	binding := sparqlTripleBinding{
		S: sparqlTerm{Type: "uri", Value: "http://example.com/s"},
		P: sparqlTerm{Type: "uri", Value: "http://example.com/p"},
		O: sparqlTerm{Type: "uri", Value: "http://example.com/o"},
	}

	acc.addTripleBinding(binding)
	acc.addTripleBinding(binding)

	if len(acc.nodes) != 2 {
		t.Fatalf("expected 2 nodes after duplicate bindings, got %d", len(acc.nodes))
	}
	if len(acc.edges) != 1 {
		t.Fatalf("expected 1 deduplicated edge, got %d", len(acc.edges))
	}
}
