github.com/DiversionCompany/notify@v0.9.9/watcher_fsevents_test.go (about) 1 // Copyright (c) 2014-2015 The Notify Authors. All rights reserved. 2 // Use of this source code is governed by the MIT license that can be 3 // found in the LICENSE file. 4 5 //go:build darwin && !kqueue && cgo 6 // +build darwin,!kqueue,cgo 7 8 package notify 9 10 import ( 11 "reflect" 12 "testing" 13 ) 14 15 func TestSplitflags(t *testing.T) { 16 cases := [...]struct { 17 set uint32 18 flags []uint32 19 }{ 20 {0, nil}, 21 {0xD, []uint32{0x1, 0x4, 0x8}}, 22 {0x0010 | 0x0040 | 0x0080 | 0x01000, []uint32{0x0010, 0x0040, 0x0080, 0x01000}}, 23 {0x40000 | 0x00100 | 0x00200, []uint32{0x00100, 0x00200, 0x40000}}, 24 } 25 for i, cas := range cases { 26 if flags := splitflags(cas.set); !reflect.DeepEqual(flags, cas.flags) { 27 t.Errorf("want flags=%v; got %v (i=%d)", cas.flags, flags, i) 28 } 29 } 30 } 31 32 // Test for cases 3) and 5) with shadowed write&create events. 33 // 34 // See comment for (flagdiff).diff method. 35 func TestWatcherShadowedWriteCreate(t *testing.T) { 36 w := NewWatcherTest(t, "testdata/vfs.txt") 37 defer w.Close() 38 39 cases := [...]WCase{ 40 // i=0 41 create(w, "src/github.com/rjeczalik/fs/.fs.go.swp"), 42 // i=1 43 write(w, "src/github.com/rjeczalik/fs/.fs.go.swp", []byte("XD")), 44 // i=2 45 write(w, "src/github.com/rjeczalik/fs/.fs.go.swp", []byte("XD")), 46 // i=3 47 remove(w, "src/github.com/rjeczalik/fs/.fs.go.swp"), 48 // i=4 49 create(w, "src/github.com/rjeczalik/fs/.fs.go.swp"), 50 // i=5 51 write(w, "src/github.com/rjeczalik/fs/.fs.go.swp", []byte("XD")), 52 } 53 54 w.ExpectAny(cases[:5]) // BUG(rjeczalik): #62 55 }