MCPcopy Create free account
hub / github.com/astercloud/aster / TestHashContent

Function TestHashContent

pkg/memory/observation_compressor_test.go:231–254  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

229}
230
231func TestHashContent(t *testing.T) {
232 content1 := "Hello, World!"
233 content2 := "Hello, World!"
234 content3 := "Different content"
235
236 hash1 := hashContent(content1)
237 hash2 := hashContent(content2)
238 hash3 := hashContent(content3)
239
240 // 相同内容应该产生相同哈希
241 if hash1 != hash2 {
242 t.Error("Same content should produce same hash")
243 }
244
245 // 不同内容应该产生不同哈希
246 if hash1 == hash3 {
247 t.Error("Different content should produce different hash")
248 }
249
250 // 哈希应该是 16 字符
251 if len(hash1) != 16 {
252 t.Errorf("Hash should be 16 chars, got %d", len(hash1))
253 }
254}
255
256func TestIsValidFilePath(t *testing.T) {
257 tests := []struct {

Callers

nothing calls this directly

Calls 2

hashContentFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected