msoleps_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package msoleps
  2. import (
  3. "os"
  4. "testing"
  5. )
  6. var (
  7. testDocSum = "test/DocumentSummaryInformation"
  8. testSum = "test/SummaryInformation"
  9. testSum1 = "test/SummaryInformation1"
  10. )
  11. func testFile(t *testing.T, path string) *Reader {
  12. file, _ := os.Open(path)
  13. defer file.Close()
  14. doc, err := NewFrom(file)
  15. if err != nil {
  16. t.Errorf("Error opening file; Returns error: %v", err)
  17. }
  18. return doc
  19. }
  20. func TestDocSum(t *testing.T) {
  21. doc := testFile(t, testDocSum)
  22. if len(doc.Property) != 12 {
  23. t.Errorf("Expecting 12 properties, got %d", len(doc.Property))
  24. }
  25. if doc.Property[1].String() != "Australian Broadcasting Corporation" {
  26. t.Errorf("Expecting 'ABC' as second property, got %s", doc.Property[1])
  27. }
  28. }
  29. func TestSum(t *testing.T) {
  30. doc := testFile(t, testSum)
  31. if len(doc.Property) != 17 {
  32. t.Errorf("Expecting 17 properties, got %d", len(doc.Property))
  33. }
  34. if doc.Property[5].String() != "Normal" {
  35. t.Errorf("Expecting 'Normal' as sixth property, got %s", doc.Property[5])
  36. }
  37. }
  38. func TestSum1(t *testing.T) {
  39. doc := testFile(t, testSum1)
  40. if len(doc.Property) != 3 {
  41. t.Errorf("Expecting 3 properties, got %d", len(doc.Property))
  42. }
  43. if doc.Property[0].String() != "Mail" {
  44. t.Errorf("Expecting 'Mail' as first property, got %s", doc.Property[0])
  45. }
  46. }