mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 21:35:33 +08:00 
			
		
		
		
	
		
			
	
	
		
			26 lines
		
	
	
		
			631 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			26 lines
		
	
	
		
			631 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								package utils_test
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import (
							 | 
						||
| 
								 | 
							
									"github.com/TeaOSLab/EdgeAdmin/internal/utils"
							 | 
						||
| 
								 | 
							
									"strings"
							 | 
						||
| 
								 | 
							
									"testing"
							 | 
						||
| 
								 | 
							
								)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func TestStringsStream_Filter(t *testing.T) {
							 | 
						||
| 
								 | 
							
									var stream = utils.NewStringsStream([]string{"a", "b", "1", "2", "", "png", "a"})
							 | 
						||
| 
								 | 
							
									stream.Filter(func(item string) bool {
							 | 
						||
| 
								 | 
							
										return len(item) > 0
							 | 
						||
| 
								 | 
							
									})
							 | 
						||
| 
								 | 
							
									t.Log(stream.Result())
							 | 
						||
| 
								 | 
							
									stream.Map(func(item string) string {
							 | 
						||
| 
								 | 
							
										return "." + item
							 | 
						||
| 
								 | 
							
									})
							 | 
						||
| 
								 | 
							
									t.Log(stream.Result())
							 | 
						||
| 
								 | 
							
									stream.Unique()
							 | 
						||
| 
								 | 
							
									t.Log(stream.Result())
							 | 
						||
| 
								 | 
							
									stream.Map(strings.ToUpper, strings.ToLower)
							 | 
						||
| 
								 | 
							
									t.Log(stream.Result())
							 | 
						||
| 
								 | 
							
								}
							 |