go-pattern-examples/structure/18_flyweight/flyweight_test.go

20 lines
360 B
Go
Raw Normal View History

2020-04-21 17:50:21 +03:00
package flyweight
import "testing"
func ExampleFlyweight() {
viewer := NewImageViewer("image1.png")
viewer.Display()
// Output:
// Display: image data image1.png
}
func TestFlyweight(t *testing.T) {
viewer1 := NewImageViewer("image1.png")
viewer2 := NewImageViewer("image1.png")
if viewer1.ImageFlyweight != viewer2.ImageFlyweight {
t.Fail()
}
}