예제 #1
0
func TestEncode7Bit(t *testing.T) {
	data := []struct {
		str string
		exp []byte
	}{
		{"hello[world]! ы?", util.MustBytes("E8329BFDDEF0EE6F399BBCF18540BF1F")},
		{"AAAAAAAAAAAAAAB\r", util.MustBytes("C16030180C0683C16030180C0A1B0D")},
		{"AAAAAAAAAAAAAAB", util.MustBytes("C16030180C0683C16030180C0A1B")},
		{"height of eifel", util.MustBytes("E872FA8CA683DE6650396D2EB31B")},
	}
	for _, d := range data {
		assert.Equal(t, d.exp, Encode7Bit(d.str))
	}
}
예제 #2
0
func TestDecode7Bit(t *testing.T) {
	data := []struct {
		exp   string
		pack7 []byte
	}{
		// ы -> ?
		{"hello[world]! ??", util.MustBytes("E8329BFDDEF0EE6F399BBCF18540BF1F")},
		{"AAAAAAAAAAAAAAB\r", util.MustBytes("C16030180C0683C16030180C0A1B0D")},
		{"AAAAAAAAAAAAAAB", util.MustBytes("C16030180C0683C16030180C0A1B")},
		{"height of eifel", util.MustBytes("E872FA8CA683DE6650396D2EB31B")},
	}
	for _, d := range data {
		log.Println(displayPack(d.pack7))
		out, err := Decode7Bit(d.pack7)
		assert.NoError(t, err)
		assert.Equal(t, d.exp, out)
	}
}