added support for string type
[govpp.git] / vendor / github.com / fsnotify / fsnotify / fsnotify_test.go
1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // +build !plan9
6
7 package fsnotify
8
9 import "testing"
10
11 func TestEventStringWithValue(t *testing.T) {
12         for opMask, expectedString := range map[Op]string{
13                 Chmod | Create: `"/usr/someFile": CREATE|CHMOD`,
14                 Rename:         `"/usr/someFile": RENAME`,
15                 Remove:         `"/usr/someFile": REMOVE`,
16                 Write | Chmod:  `"/usr/someFile": WRITE|CHMOD`,
17         } {
18                 event := Event{Name: "/usr/someFile", Op: opMask}
19                 if event.String() != expectedString {
20                         t.Fatalf("Expected %s, got: %v", expectedString, event.String())
21                 }
22
23         }
24 }
25
26 func TestEventOpStringWithValue(t *testing.T) {
27         expectedOpString := "WRITE|CHMOD"
28         event := Event{Name: "someFile", Op: Write | Chmod}
29         if event.Op.String() != expectedOpString {
30                 t.Fatalf("Expected %s, got: %v", expectedOpString, event.Op.String())
31         }
32 }
33
34 func TestEventOpStringWithNoValue(t *testing.T) {
35         expectedOpString := ""
36         event := Event{Name: "testFile", Op: 0}
37         if event.Op.String() != expectedOpString {
38                 t.Fatalf("Expected %s, got: %v", expectedOpString, event.Op.String())
39         }
40 }