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.
		
		
		
		
		
			
		
			
				
					
					
						
							31 lines
						
					
					
						
							762 B
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							31 lines
						
					
					
						
							762 B
						
					
					
				
								package weed_server
							 | 
						|
								
							 | 
						|
								import (
							 | 
						|
									"github.com/stretchr/testify/assert"
							 | 
						|
									"github.com/viant/ptrie"
							 | 
						|
									"testing"
							 | 
						|
								)
							 | 
						|
								
							 | 
						|
								func TestPtrie(t *testing.T) {
							 | 
						|
									b := []byte("/topics/abc/dev")
							 | 
						|
									excludedTrie := ptrie.New[bool]()
							 | 
						|
									excludedTrie.Put([]byte("/topics/abc/d"), true)
							 | 
						|
									excludedTrie.Put([]byte("/topics/abc"), true)
							 | 
						|
								
							 | 
						|
									assert.True(t, excludedTrie.MatchPrefix(b, func(key []byte, value bool) bool {
							 | 
						|
										println("matched1", string(key))
							 | 
						|
										return true
							 | 
						|
									}))
							 | 
						|
								
							 | 
						|
									assert.True(t, excludedTrie.MatchAll(b, func(key []byte, value bool) bool {
							 | 
						|
										println("matched2", string(key))
							 | 
						|
										return true
							 | 
						|
									}))
							 | 
						|
								
							 | 
						|
									assert.False(t, excludedTrie.MatchAll([]byte("/topics/ab"), func(key []byte, value bool) bool {
							 | 
						|
										println("matched3", string(key))
							 | 
						|
										return true
							 | 
						|
									}))
							 | 
						|
								
							 | 
						|
									assert.False(t, excludedTrie.Has(b))
							 | 
						|
								}
							 |