Files
software-station/software-verifier/main_test.go
Sudo-Ivan c58384285a Add SHA256 computation and verification functionality
- Implemented computeSHA256 function to generate hex-encoded SHA256 hashes.
- Added verifySHA256 function to validate input data against expected hash in a WebAssembly context.
- Created main_test.go to include unit tests for computeSHA256 with various input cases.
2025-12-27 15:32:42 -06:00

40 lines
821 B
Go

package main
import (
"testing"
)
func TestComputeSHA256(t *testing.T) {
tests := []struct {
name string
input string
expected string
}{
{
name: "Empty string",
input: "",
expected: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
},
{
name: "Hello world",
input: "hello world",
expected: "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
},
{
name: "Software Station",
input: "Software Station",
expected: "2f94338443740cd0ca2afbd1c177f8a624a521d1668d9eaf4e2439ae06e32b11",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
actual := computeSHA256([]byte(tt.input))
if actual != tt.expected {
t.Errorf("computeSHA256() = %v, want %v", actual, tt.expected)
}
})
}
}