object_test.go 580 B

123456789101112131415161718192021
  1. package object
  2. import "testing"
  3. func TestStringHashKey(t *testing.T) {
  4. hello1 := &String{Value: "Hello World"}
  5. hello2 := &String{Value: "Hello World"}
  6. diff1 := &String{Value: "My name is johnny"}
  7. diff2 := &String{Value: "My name is johnny"}
  8. if hello1.HashKey() != hello2.HashKey() {
  9. t.Errorf("strings with same content have different hash keys")
  10. }
  11. if diff1.HashKey() != diff2.HashKey() {
  12. t.Errorf("strings with same content have different hash keys")
  13. }
  14. if hello1.HashKey() == diff1.HashKey() {
  15. t.Errorf("strings with different content have same hash keys")
  16. }
  17. }