@@ -29,9 +29,8 @@ func TestDefaultCache_StoreAndLoad(t *testing.T) {
2929 CompiledSchema : & jsonschema.Schema {},
3030 }
3131
32- // Create a test key (32-byte hash)
33- var key [32 ]byte
34- copy (key [:], []byte ("test-schema-hash-12345678901234" ))
32+ // Create a test key (uint64 hash)
33+ key := uint64 (0x123456789abcdef0 )
3534
3635 // Store the schema
3736 cache .Store (key , testSchema )
@@ -49,8 +48,7 @@ func TestDefaultCache_LoadMissing(t *testing.T) {
4948 cache := NewDefaultCache ()
5049
5150 // Try to load a key that doesn't exist
52- var key [32 ]byte
53- copy (key [:], []byte ("nonexistent-key-12345678901234" ))
51+ key := uint64 (0xdeadbeef )
5452
5553 loaded , ok := cache .Load (key )
5654 assert .False (t , ok , "Should not find non-existent key" )
@@ -60,7 +58,7 @@ func TestDefaultCache_LoadMissing(t *testing.T) {
6058func TestDefaultCache_LoadNilCache (t * testing.T ) {
6159 var cache * DefaultCache
6260
63- var key [ 32 ] byte
61+ key := uint64 ( 0 )
6462 loaded , ok := cache .Load (key )
6563
6664 assert .False (t , ok )
@@ -71,7 +69,7 @@ func TestDefaultCache_StoreNilCache(t *testing.T) {
7169 var cache * DefaultCache
7270
7371 // Should not panic
74- var key [ 32 ] byte
72+ key := uint64 ( 0 )
7573 cache .Store (key , & SchemaCacheEntry {})
7674
7775 // Verify nothing was stored (cache is nil)
@@ -82,10 +80,9 @@ func TestDefaultCache_Range(t *testing.T) {
8280 cache := NewDefaultCache ()
8381
8482 // Store multiple entries
85- entries := make (map [[ 32 ] byte ]* SchemaCacheEntry )
83+ entries := make (map [uint64 ]* SchemaCacheEntry )
8684 for i := 0 ; i < 5 ; i ++ {
87- var key [32 ]byte
88- copy (key [:], []byte {byte (i )})
85+ key := uint64 (i )
8986
9087 entry := & SchemaCacheEntry {
9188 RenderedInline : []byte {byte (i )},
@@ -97,8 +94,8 @@ func TestDefaultCache_Range(t *testing.T) {
9794
9895 // Range over all entries
9996 count := 0
100- foundKeys := make (map [[ 32 ] byte ]bool )
101- cache .Range (func (key [ 32 ] byte , value * SchemaCacheEntry ) bool {
97+ foundKeys := make (map [uint64 ]bool )
98+ cache .Range (func (key uint64 , value * SchemaCacheEntry ) bool {
10299 count ++
103100 foundKeys [key ] = true
104101
@@ -118,14 +115,13 @@ func TestDefaultCache_RangeEarlyTermination(t *testing.T) {
118115
119116 // Store multiple entries
120117 for i := 0 ; i < 10 ; i ++ {
121- var key [32 ]byte
122- copy (key [:], []byte {byte (i )})
118+ key := uint64 (i )
123119 cache .Store (key , & SchemaCacheEntry {})
124120 }
125121
126122 // Range but stop after 3 iterations
127123 count := 0
128- cache .Range (func (key [ 32 ] byte , value * SchemaCacheEntry ) bool {
124+ cache .Range (func (key uint64 , value * SchemaCacheEntry ) bool {
129125 count ++
130126 return count < 3 // Stop after 3
131127 })
@@ -138,7 +134,7 @@ func TestDefaultCache_RangeNilCache(t *testing.T) {
138134
139135 // Should not panic
140136 called := false
141- cache .Range (func (key [ 32 ] byte , value * SchemaCacheEntry ) bool {
137+ cache .Range (func (key uint64 , value * SchemaCacheEntry ) bool {
142138 called = true
143139 return true
144140 })
@@ -151,7 +147,7 @@ func TestDefaultCache_RangeEmpty(t *testing.T) {
151147
152148 // Range over empty cache
153149 count := 0
154- cache .Range (func (key [ 32 ] byte , value * SchemaCacheEntry ) bool {
150+ cache .Range (func (key uint64 , value * SchemaCacheEntry ) bool {
155151 count ++
156152 return true
157153 })
@@ -162,8 +158,7 @@ func TestDefaultCache_RangeEmpty(t *testing.T) {
162158func TestDefaultCache_Overwrite (t * testing.T ) {
163159 cache := NewDefaultCache ()
164160
165- var key [32 ]byte
166- copy (key [:], []byte ("test-key" ))
161+ key := uint64 (0x12345678 )
167162
168163 // Store first value
169164 first := & SchemaCacheEntry {
@@ -188,10 +183,9 @@ func TestDefaultCache_MultipleKeys(t *testing.T) {
188183 cache := NewDefaultCache ()
189184
190185 // Store with different keys
191- var key1 , key2 , key3 [32 ]byte
192- copy (key1 [:], []byte ("key1" ))
193- copy (key2 [:], []byte ("key2" ))
194- copy (key3 [:], []byte ("key3" ))
186+ key1 := uint64 (1 )
187+ key2 := uint64 (2 )
188+ key3 := uint64 (3 )
195189
196190 cache .Store (key1 , & SchemaCacheEntry {RenderedInline : []byte ("value1" )})
197191 cache .Store (key2 , & SchemaCacheEntry {RenderedInline : []byte ("value2" )})
@@ -218,8 +212,7 @@ func TestDefaultCache_ThreadSafety(t *testing.T) {
218212 done := make (chan bool , 10 )
219213 for i := 0 ; i < 10 ; i ++ {
220214 go func (val int ) {
221- var key [32 ]byte
222- copy (key [:], []byte {byte (val )})
215+ key := uint64 (val )
223216 cache .Store (key , & SchemaCacheEntry {
224217 RenderedInline : []byte {byte (val )},
225218 })
@@ -235,8 +228,7 @@ func TestDefaultCache_ThreadSafety(t *testing.T) {
235228 // Concurrent reads
236229 for i := 0 ; i < 10 ; i ++ {
237230 go func (val int ) {
238- var key [32 ]byte
239- copy (key [:], []byte {byte (val )})
231+ key := uint64 (val )
240232 loaded , ok := cache .Load (key )
241233 assert .True (t , ok )
242234 assert .NotNil (t , loaded )
@@ -251,7 +243,7 @@ func TestDefaultCache_ThreadSafety(t *testing.T) {
251243
252244 // Verify all entries exist
253245 count := 0
254- cache .Range (func (key [ 32 ] byte , value * SchemaCacheEntry ) bool {
246+ cache .Range (func (key uint64 , value * SchemaCacheEntry ) bool {
255247 count ++
256248 return true
257249 })
@@ -284,20 +276,18 @@ func TestDefaultCache_RangeWithInvalidTypes(t *testing.T) {
284276 cache .m .Store ("invalid-key-type" , & SchemaCacheEntry {})
285277
286278 // Store an entry with wrong value type
287- var validKey [32 ]byte
288- copy (validKey [:], []byte {1 })
279+ validKey := uint64 (1 )
289280 cache .m .Store (validKey , "invalid-value-type" )
290281
291282 // Store a valid entry
292- var validKey2 [32 ]byte
293- copy (validKey2 [:], []byte {2 })
283+ validKey2 := uint64 (2 )
294284 validEntry := & SchemaCacheEntry {RenderedInline : []byte ("valid" )}
295285 cache .Store (validKey2 , validEntry )
296286
297287 // Range should skip invalid entries and only process valid ones
298288 count := 0
299289 var seenEntry * SchemaCacheEntry
300- cache .Range (func (key [ 32 ] byte , value * SchemaCacheEntry ) bool {
290+ cache .Range (func (key uint64 , value * SchemaCacheEntry ) bool {
301291 count ++
302292 seenEntry = value
303293 return true
0 commit comments