base64_test.go 905 B

123456789101112131415161718192021222324252627
  1. package stdlib_test
  2. import "testing"
  3. var base64Bytes1 = []byte{
  4. 0x06, 0xAC, 0x76, 0x1B, 0x1D, 0x6A, 0xFA, 0x9D, 0xB1, 0xA0,
  5. }
  6. const (
  7. base64Std = "Bqx2Gx1q+p2xoA=="
  8. base64URL = "Bqx2Gx1q-p2xoA=="
  9. base64RawStd = "Bqx2Gx1q+p2xoA"
  10. base64RawURL = "Bqx2Gx1q-p2xoA"
  11. )
  12. func TestBase64(t *testing.T) {
  13. module(t, `base64`).call("encode", base64Bytes1).expect(base64Std)
  14. module(t, `base64`).call("decode", base64Std).expect(base64Bytes1)
  15. module(t, `base64`).call("url_encode", base64Bytes1).expect(base64URL)
  16. module(t, `base64`).call("url_decode", base64URL).expect(base64Bytes1)
  17. module(t, `base64`).call("raw_encode", base64Bytes1).expect(base64RawStd)
  18. module(t, `base64`).call("raw_decode", base64RawStd).expect(base64Bytes1)
  19. module(t, `base64`).call("raw_url_encode", base64Bytes1).
  20. expect(base64RawURL)
  21. module(t, `base64`).call("raw_url_decode", base64RawURL).
  22. expect(base64Bytes1)
  23. }