mirror of
				https://github.com/taigrr/wtf
				synced 2025-01-18 04:03:14 -08:00 
			
		
		
		
	Add a few more tests (#1056)
* Add test for SumInts() * Add a few more tests in utils * Minor update for SumInts test
This commit is contained in:
		
							parent
							
								
									7c12523139
								
							
						
					
					
						commit
						cf3229e0cd
					
				
							
								
								
									
										24
									
								
								utils/sums_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								utils/sums_test.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| package utils | ||||
| 
 | ||||
| import ( | ||||
| 	"testing" | ||||
| 
 | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| ) | ||||
| 
 | ||||
| func Test_SumInts(t *testing.T) { | ||||
| 	expected := 6 | ||||
| 	result := SumInts([]int{1, 3, 2}) | ||||
| 
 | ||||
| 	assert.Equal(t, expected, result) | ||||
| 
 | ||||
| 	expected = 46 | ||||
| 	result = SumInts([]int{4, 6, 7, 23, 6}) | ||||
| 
 | ||||
| 	assert.Equal(t, expected, result) | ||||
| 
 | ||||
| 	expected = 4 | ||||
| 	result = SumInts([]int{4}) | ||||
| 
 | ||||
| 	assert.Equal(t, expected, result) | ||||
| } | ||||
| @ -204,7 +204,7 @@ func MaxInt(x, y int) int { | ||||
| // | ||||
| // Examples: | ||||
| // | ||||
| //   clamp(6, 3, 8) => 4 | ||||
| //   clamp(6, 3, 8) => 6 | ||||
| //   clamp(1, 3, 8) => 3 | ||||
| //   clamp(9, 3, 8) => 8 | ||||
| // | ||||
|  | ||||
| @ -131,3 +131,32 @@ func Test_ReadFileBytes(t *testing.T) { | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func Test_MaxInt(t *testing.T) { | ||||
| 	expected := 3 | ||||
| 	result := MaxInt(3, 2) | ||||
| 
 | ||||
| 	assert.Equal(t, expected, result) | ||||
| 
 | ||||
| 	expected = 3 | ||||
| 	result = MaxInt(2, 3) | ||||
| 
 | ||||
| 	assert.Equal(t, expected, result) | ||||
| } | ||||
| 
 | ||||
| func Test_Clamp(t *testing.T) { | ||||
| 	expected := 6 | ||||
| 	result := Clamp(6, 3, 8) | ||||
| 
 | ||||
| 	assert.Equal(t, expected, result) | ||||
| 
 | ||||
| 	expected = 3 | ||||
| 	result = Clamp(1, 3, 8) | ||||
| 
 | ||||
| 	assert.Equal(t, expected, result) | ||||
| 
 | ||||
| 	expected = 8 | ||||
| 	result = Clamp(9, 3, 8) | ||||
| 
 | ||||
| 	assert.Equal(t, expected, result) | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user