forked from meshifyiot/paho.mqtt.golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit_topic_test.go
47 lines (41 loc) · 1.06 KB
/
unit_topic_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
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Copyright (c) 2013 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Seth Hoenig
* Allan Stockdill-Mander
* Mike Robertson
*/
package mqtt
import (
"testing"
)
func Test_ValidateTopicAndQos_qos3(t *testing.T) {
e := validateTopicAndQos("a", 3)
if e != ErrInvalidQos {
t.Fatalf("invalid error for invalid qos")
}
}
func Test_ValidateTopicAndQos_ES(t *testing.T) {
e := validateTopicAndQos("", 0)
if e != ErrInvalidTopicEmptyString {
t.Fatalf("invalid error for empty topic name")
}
}
func Test_ValidateTopicAndQos_a_0(t *testing.T) {
e := validateTopicAndQos("a", 0)
if e != nil {
t.Fatalf("error from valid NewTopicFilter")
}
}
func Test_ValidateTopicAndQos_H(t *testing.T) {
e := validateTopicAndQos("a/#/c", 0)
if e != ErrInvalidTopicMultilevel {
t.Fatalf("invalid error for bad multilevel topic filter")
}
}