conf_test.go 844 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package conf_test
  2. import (
  3. "leafstalk/conf"
  4. "testing"
  5. )
  6. func TestCompareMaps(t *testing.T) {
  7. map1 := map[string]interface{}{
  8. "key1": 5,
  9. "key2": "hello",
  10. "key3": true,
  11. "key4": 3.14,
  12. "key5": []int{1, 2, 3},
  13. "key6": map[string]interface{}{
  14. "nestedKey1": "nestedValue1",
  15. "nestedKey2": 10,
  16. },
  17. "key7": []map[string]int{
  18. {"nestedKey3": 20},
  19. {"nestedKey4": 30},
  20. },
  21. "key8": [3]string{"a", "b", "c"},
  22. }
  23. map2 := map[string]interface{}{
  24. "key1": 5,
  25. "key2": "world",
  26. "key3": true,
  27. "key4": 3.14,
  28. "key5": []int{1, 2, 3},
  29. "key6": map[string]interface{}{
  30. "nestedKey1": "nestedValue2",
  31. "nestedKey2": 10,
  32. },
  33. "key7": []map[string]int{
  34. {"nestedKey3": 20},
  35. {"nestedKey4": 40},
  36. },
  37. "key8": [3]string{"a", "b", "d"},
  38. }
  39. diffKeys := conf.CompareMaps(map1, map2)
  40. t.Logf("diffKeys:%v", diffKeys)
  41. }