Permalink
Browse files

mmvdump: add a basic test

  • Loading branch information...
1 parent 3a6bb89 commit 0807418053e9207ba9f417bbf77b59eaeea69e31 @suyash suyash committed Jul 25, 2016
Showing with 55 additions and 0 deletions.
  1. +55 −0 mmvdump/mmvdump_test.go
View
@@ -0,0 +1,55 @@
+package mmvdump
+
+import (
+ "os"
+ "testing"
+)
+
+func TestMmvDump1(t *testing.T) {
+ f, err := os.Open("testdata/test1.mmv")
+ if err != nil {
+ panic(err)
+ }
+
+ s, err := os.Stat("testdata/test1.mmv")
+ if err != nil {
+ panic(err)
+ }
+
+ data := make([]byte, s.Size())
+ f.Read(data)
+
+ h, tocs, metrics, values, instances, indoms, strings, err := Dump(data)
+ if err != nil {
+ t.Error(err)
+ return
+ }
+
+ if h.G1 != h.G2 {
+ t.Error("Invalid Header")
+ }
+
+ if len(tocs) != 3 {
+ t.Errorf("expected number of tocs %d, got %d", 3, len(tocs))
+ }
+
+ if len(indoms) != 0 {
+ t.Errorf("expected number of indoms %d, got %d", 0, len(indoms))
+ }
+
+ if len(strings) != 2 {
+ t.Errorf("expected number of strings %d, got %d", 2, len(strings))
+ }
+
+ if len(metrics) != 1 {
+ t.Errorf("expected number of strings %d, got %d", 1, len(metrics))
+ }
+
+ if len(values) != 1 {
+ t.Errorf("expected number of strings %d, got %d", 1, len(values))
+ }
+
+ if len(instances) != 0 {
+ t.Errorf("expected number of strings %d, got %d", 0, len(instances))
+ }
+}

0 comments on commit 0807418

Please sign in to comment.