Skip to content

Commit

Permalink
move commented code to test file
Browse files Browse the repository at this point in the history
  • Loading branch information
bakurits committed Jun 14, 2020
1 parent 5fcb9e4 commit 0f34f65
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
21 changes: 1 addition & 20 deletions data-structures/hash-map/hash_map.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hash_map
package hashmap

import (
"fmt"
Expand Down Expand Up @@ -125,22 +125,3 @@ func (hm *HashMap) hash(key interface{}) uint64 {

return (hm.capacity - 1) & (hashValue ^ (hashValue >> 16))
}

// func main() {
// HashMap := New()

// HashMap.Put("test-1", 10)
// fmt.Println(HashMap.Get("test-1"))

// HashMap.Put("test-1", 20)
// HashMap.Put("test-2", 30)
// HashMap.Put(1, 40)

// fmt.Println(HashMap.Get("test-1"))
// fmt.Println(HashMap.Get("test-2"))
// fmt.Println(HashMap.Get(1))

// fmt.Println(HashMap.Contains(2))
// fmt.Println(HashMap.Contains(1))
// fmt.Println(HashMap.Contains("test-1"))
// }
28 changes: 28 additions & 0 deletions data-structures/hash-map/hash_map_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package hashmap_test

import (
hashmap "TheAlgorithms/Go/data-structures/hash-map"
"fmt"
"testing"
)

func TestHashMap_Contains(t *testing.T) {

mp := hashmap.New()

mp.Put("test-1", 10)
fmt.Println(mp.Get("test-1"))

mp.Put("test-1", 20)
mp.Put("test-2", 30)
mp.Put(1, 40)

fmt.Println(mp.Get("test-1"))
fmt.Println(mp.Get("test-2"))
fmt.Println(mp.Get(1))

fmt.Println(mp.Contains(2))
fmt.Println(mp.Contains(1))
fmt.Println(mp.Contains("test-1"))

}

0 comments on commit 0f34f65

Please sign in to comment.