challenge_test.go 807 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package model
  2. import (
  3. "testing"
  4. "github.com/smartystreets/goconvey/convey"
  5. )
  6. var c *Chall
  7. func init() {
  8. c = new(Chall)
  9. }
  10. func TestSetState(t *testing.T) {
  11. convey.Convey("SetState", t, func() {
  12. c.DispatchState = uint32(0x3a4b5c6d)
  13. state := uint32(0xf)
  14. role := uint8(1)
  15. c.SetState(state, role)
  16. convey.So(c.DispatchState, convey.ShouldEqual, uint32(0x3a4b5cfd))
  17. })
  18. }
  19. func TestGetState(t *testing.T) {
  20. convey.Convey("GetState", t, func() {
  21. c.DispatchState = uint32(0x3a4b5c6d)
  22. role := uint8(2)
  23. result := c.getState(role)
  24. convey.So(result, convey.ShouldEqual, uint32(0xc))
  25. })
  26. }
  27. func TestFormatState(t *testing.T) {
  28. convey.Convey("FormatState", t, func() {
  29. c.FormatState()
  30. })
  31. }
  32. func TestFromState(t *testing.T) {
  33. convey.Convey("FromState", t, func() {
  34. c.FromState()
  35. })
  36. }