Skip to content

Commit

Permalink
assert module updated
Browse files Browse the repository at this point in the history
  • Loading branch information
andygeiss committed Jun 28, 2020
1 parent 61cb3a9 commit a9a0cc9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
6 changes: 3 additions & 3 deletions digital/digital_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ func TestDigitalWrite(t *testing.T) {
pin := 1
digital.GPIOValues[pin] = digital.Low
digital.Write(pin, digital.High)
mode := digital.GPIOValues[pin]
assert.That(t, mode, digital.High)
val := digital.GPIOValues[pin]
assert.That("val is set to high", t, val, digital.High)
}

func TestPinMode(t *testing.T) {
pin := 1
digital.GPIOModes[pin] = digital.ModeInput
digital.PinMode(pin, digital.ModeOutput)
mode := digital.GPIOModes[pin]
assert.That(t, mode, digital.ModeOutput)
assert.That("mode is set to output", t, mode, digital.ModeOutput)
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/andygeiss/esp32-controller

go 1.12
go 1.14

require github.com/andygeiss/assert v0.0.6
require github.com/andygeiss/assert v0.0.9
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github.com/andygeiss/assert v0.0.6 h1:FyiAIudVwnxp55GIcNOaZ2ABr8n2RI9SXmaXG7+Y53o=
github.com/andygeiss/assert v0.0.6/go.mod h1:ztUvWrfUo43X0zMA1XfX8esn5Uavk6ANSKTT0w2qvAI=
github.com/andygeiss/assert v0.0.9 h1:ZITUqQiyeBo7hXROIb50vKV2jeSAy/R9CD9UkxxS3w4=
github.com/andygeiss/assert v0.0.9/go.mod h1:fCwXr8GkRVuJWDwiCS73+NTcHXyhQSx4uqV/0Fl5T3g=
10 changes: 6 additions & 4 deletions random/random_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@ import (

func TestNum(t *testing.T) {
num := random.Num(10)
assert.That(t, num, 0)
assert.That("num is max 10", t, num <= 10, true)
}

func TestNumXY(t *testing.T) {
x := random.Num(100)
y := random.Num(100)
assert.That(t, x, y)
assert.That("x and y are not equal", t, x != y, true)
}

func TestNumBetween(t *testing.T) {
num := random.NumBetween(100, 200)
between100And200 := num >= 100 && num <= 200
assert.That(t, between100And200, true)
assert.That("num is between 100 and 200", t, between100And200, true)
}

func TestSeed(t *testing.T) {
random.Seed(42)
x := random.Num(100)
y := random.Num(100)
assert.That(t, x, y)
assert.That("x and y are not equal", t, x != y, true)
assert.That("x is max 100", t, x <= 100, true)
assert.That("y is max 100", t, y <= 100, true)
}
2 changes: 1 addition & 1 deletion serial/serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ func TestSerialBegin(t *testing.T) {
baud := serial.BaudRate115200
serial.Baud = 0
serial.Begin(baud)
assert.That(t, serial.Baud, serial.BaudRate115200)
assert.That("baud rate is 115200", t, serial.Baud, serial.BaudRate115200)
}
12 changes: 6 additions & 6 deletions wifi/wifi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func TestWifiBegin(t *testing.T) {
ssid := "test"
wifi.CurrentStatus = wifi.StatusIdle
wifi.Begin(ssid)
assert.That(t, wifi.CurrentStatus, wifi.StatusConnected)
assert.That("current status is connected", t, wifi.CurrentStatus, wifi.StatusConnected)
}

func TestWifiBeginEncrypted(t *testing.T) {
Expand All @@ -19,26 +19,26 @@ func TestWifiBeginEncrypted(t *testing.T) {
ipv4 := &wifi.IPAddress{127, 0, 0, 1}
wifi.CurrentStatus = wifi.StatusIdle
wifi.BeginEncrypted(ssid, passphrase)
assert.That(t, wifi.CurrentStatus, wifi.StatusConnected)
assert.That(t, wifi.CurrentLocalIP, ipv4)
assert.That("current status is connected", t, wifi.CurrentStatus, wifi.StatusConnected)
assert.That("current local ip is ipv4", t, wifi.CurrentLocalIP, ipv4)
}
func TestWifiDisBegin(t *testing.T) {
ssid := "test"
wifi.CurrentStatus = wifi.StatusIdle
wifi.Begin(ssid) // StatusConnected
wifi.Disconnect() // back to idle?
assert.That(t, wifi.CurrentStatus, wifi.StatusIdle)
assert.That("current status is idle", t, wifi.CurrentStatus, wifi.StatusIdle)
}

func TestWifiRSSIShouldBeNotMinusOne(t *testing.T) {
ssid := "test"
wifi.CurrentRSSI = -1
wifi.Begin(ssid)
assert.That(t, wifi.RSSI(), -1)
assert.That("RSSI is set to 0", t, wifi.RSSI(), 0)
}
func TestWifiSSIDShouldNotBeEmpty(t *testing.T) {
ssid := "test"
wifi.CurrentSSID = ""
wifi.Begin(ssid)
assert.That(t, wifi.SSID(), "")
assert.That("SSID is set to test", t, wifi.SSID(), "test")
}

0 comments on commit a9a0cc9

Please sign in to comment.