File: nzaat_test.go

package info (click to toggle)
golang-nzaat 1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 56 kB
  • sloc: makefile: 4
file content (69 lines) | stat: -rw-r--r-- 1,220 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2013 Tonnerre Lombard <tonnerre@ancient-solutions.com>
// All rights reserved.
// Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.

package nzaat

import (
	"hash"
	"testing"
	)

// Test the hash of an empty string.
func TestEmpty(t *testing.T) {
	var h hash.Hash32 = New()
	var res uint32 = h.Sum32()

	t.Logf("NZAAT(\"\") = %x\n", res)

	if res != 0 {
		t.Fail()
	}
}

// Test the hash of a string with just "a" in it.
func TestStringA(t *testing.T) {
	var h hash.Hash32 = New()
	var res uint32

	h.Write([]byte("a"))
	res = h.Sum32()

	t.Logf("NZAAT(\"a\") = %x\n", res)

	if res != 0xc31517c4 {
		t.Fail()
	}
}

// Test the hash of a string with "abc" in it.
func TestStringABC(t *testing.T) {
	var h hash.Hash32 = New()
	var res uint32

	h.Write([]byte("abc"))
	res = h.Sum32()

	t.Logf("NZAAT(\"abc\") = %x\n", res)

	if res != 0xC3E39E2D {
		t.Fail()
	}
}

// Test the hash of a string with "message digest" in it.
func TestStringMessageDigest(t *testing.T) {
	var h hash.Hash32 = New()
	var res uint32

	h.Write([]byte("message digest"))
	res = h.Sum32()

	t.Logf("NZAAT(\"message digest\") = %x\n", res)

	if res != 0x434B78B4 {
		t.Fail()
	}
}