|
| 1 | +const linearSearch = require('../../../algorithms/searching/linear-search/index.js'); |
| 2 | + |
| 3 | +describe('Linear Search', () => { |
| 4 | + it('alvo: 7, lista(1,3,5,7,9,11,13)', () => { |
| 5 | + const array = [1, 3, 5, 7, 9, 11, 13]; |
| 6 | + const target = 7; |
| 7 | + const result = linearSearch(array, target); |
| 8 | + expect(result).toBe(3); |
| 9 | + }); |
| 10 | + |
| 11 | + it('alvo: 4, lista(1,3,5,7,9,11,13)', () => { |
| 12 | + const array = [1, 3, 5, 7, 9, 11, 13]; |
| 13 | + const target = 4; |
| 14 | + const result = linearSearch(array, target); |
| 15 | + expect(result).toBe(-1); |
| 16 | + }); |
| 17 | + |
| 18 | + it('alvo: 5, lista(5)', () => { |
| 19 | + const array = [5]; |
| 20 | + const target = 5; |
| 21 | + const result = linearSearch(array, target); |
| 22 | + expect(result).toBe(0); |
| 23 | + }); |
| 24 | + |
| 25 | + it('alvo: 1, lista(vazia)', () => { |
| 26 | + const array = []; |
| 27 | + const target = 1; |
| 28 | + const result = linearSearch(array, target); |
| 29 | + expect(result).toBe(-1); |
| 30 | + }); |
| 31 | +}); |
0 commit comments