github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/integration/messagebus/glue/utils/utils_test.go (about) 1 /* 2 * Glue - Robust Go and Javascript Socket Library 3 * Copyright (C) 2015 Roland Singer <roland.singer[at]desertbit.com> 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 package utils 20 21 import ( 22 "testing" 23 ) 24 25 func TestUnmarshalValues(t *testing.T) { 26 first, second, err := UnmarshalValues(MarshalValues("1", "2")) 27 if err != nil { 28 t.Error(err.Error()) 29 } else if first != "1" || second != "2" { 30 t.Fail() 31 } 32 33 first, second, err = UnmarshalValues(MarshalValues("1s"+delimiter+"jsd", "efsf2"+delimiter+"9as")) 34 if err != nil { 35 t.Error(err.Error()) 36 } else if first != "1s"+delimiter+"jsd" || second != "efsf2"+delimiter+"9as" { 37 t.Fail() 38 } 39 40 first, second, err = UnmarshalValues("11" + delimiter + "firstsecond") 41 if err != nil { 42 t.Error(err.Error()) 43 } else if first != "firstsecond" || second != "" { 44 t.Fail() 45 } 46 47 first, second, err = UnmarshalValues("12" + delimiter + "firstsecond") 48 if err == nil { 49 t.Fail() 50 } 51 }