File: base32_spec.lua

package info (click to toggle)
lua-basexx 0.3-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 132 kB
  • sloc: makefile: 6
file content (24 lines) | stat: -rw-r--r-- 811 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
basexx = require( "basexx" )

describe( "should handle base32(rfc3548) strings", function()
   
   it( "should convert chunky bacon", function()
      -- https://github.com/stesla/base32
      assert.is.same( "MNUHK3TLPEQGEYLDN5XCC===",
                      basexx.to_base32( "chunky bacon!" ) )
      assert.is.same( "chunky bacon!",
                      basexx.from_base32( "MNUHK3TLPEQGEYLDN5XCC===" ) )
   end)

   it( "should allow to ignore characters in a base32 string", function()
      assert.is.same( "chunky bacon!",
                      basexx.from_base32( "MNUHK3TLPEQGEYLDN5XCC===" ) )
   end)

   it ( "should handle wrong characters without a crash", function()
      local res, err = basexx.from_base32( "MS$DF" )
      assert.is.falsy( res )
      assert.is.same( "$", err )
   end)

end)