You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.0 KiB

  1. // Use of this source code is governed by an ISC
  2. // license that can be found in the LICENSE file.
  3. package nist
  4. import "testing"
  5. ////////////////
  6. func TestGet(t *testing.T) {
  7. if ln := len(Get(0)); 0 != ln {
  8. t.Errorf("Get: expected length: %d, got %d", 0, ln)
  9. }
  10. if ln := len(Get(1)); 1 != ln {
  11. t.Errorf("Get: expected length: %d, got %d", 1, ln)
  12. }
  13. }
  14. func TestHashIsEqual(t *testing.T) {
  15. var a = []byte{0x00, 0x01}
  16. var b = []byte{0x00, 0x01}
  17. var c = []byte{0x01, 0x02}
  18. var d = []byte{0x01, 0x02, 0x03}
  19. if !IsEqual(a, a) {
  20. t.Errorf("HashIsEqual: expected true, got false")
  21. }
  22. if !IsEqual(a, b) {
  23. t.Errorf("HashIsEqual: expected true, got false")
  24. }
  25. if IsEqual(a, c) {
  26. t.Errorf("HashIsEqual: expected false, got true")
  27. }
  28. if IsEqual(c, d) {
  29. t.Errorf("HashIsEqual: expected false, got true")
  30. }
  31. if IsEqual(a, nil) {
  32. t.Errorf("HashIsEqual: expected false, got true")
  33. }
  34. if IsEqual(nil, b) {
  35. t.Errorf("HashIsEqual: expected false, got true")
  36. }
  37. if !IsEqual(nil, nil) {
  38. t.Errorf("HashIsEqual: expected true, got false")
  39. }
  40. }