forked from OpenPrinting/ipp-usb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uuid_test.go
34 lines (30 loc) · 1.11 KB
/
uuid_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* ipp-usb - HTTP reverse proxy, backed by IPP-over-USB connection to device
*
* Copyright (C) 2020 and up by Alexander Pevzner ([email protected])
* See LICENSE for license terms and conditions
*
* UUID normalizer test
*/
package main
import (
"testing"
)
// Don't forget to update testData when ipp-ini.conf changes
var testDataUUID = []struct{ in, out string }{
{"01234567-89ab-cdef-0123-456789abcdef", "01234567-89ab-cdef-0123-456789abcdef"},
{"01234567-89ab-cdef-0123-456789abcde", ""},
{"01234567-89ab-cdef-0123-456789abcdef0", ""},
{"urn:01234567-89ab-cdef-0123-456789abcdef", "01234567-89ab-cdef-0123-456789abcdef"},
{"urn:uuid:01234567-89ab-cdef-0123-456789abcdef", "01234567-89ab-cdef-0123-456789abcdef"},
{"0123456789abcdef0123456789abcdef", "01234567-89ab-cdef-0123-456789abcdef"},
{"{0123456789abcdef0123456789abcdef}", "01234567-89ab-cdef-0123-456789abcdef"},
}
// Test .INI reader
func TestUUIDNormalize(t *testing.T) {
for _, data := range testDataUUID {
uuid := UUIDNormalize(data.in)
if uuid != data.out {
t.Errorf("UUIDNormalize(%q): extected %q, got %q", data.in, data.out, uuid)
}
}
}