Class: TestEan

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_model/ean13.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) test_Ean13_checksum



36
37
38
39
40
# File 'test/test_model/ean13.rb', line 36

def test_Ean13_checksum
  result = ODDB::Ean13.checksum("768045114015")
  expected = "4"
  assert_equal(expected, result)  
end

- (Object) test_Ean13_checksum2



41
42
43
44
45
# File 'test/test_model/ean13.rb', line 41

def test_Ean13_checksum2
  result = ODDB::Ean13.checksum("768048869017")
  expected = "2"
  assert_equal(expected, result)  
end

- (Object) test_Ean13_checksum3



46
47
48
49
50
# File 'test/test_model/ean13.rb', line 46

def test_Ean13_checksum3
  result = ODDB::Ean13.checksum("7680007007747")
  expected = "0"
  assert_equal(expected, result)  
end

- (Object) test_initialize2



26
27
28
29
30
# File 'test/test_model/ean13.rb', line 26

def test_initialize2
  result = ODDB::Ean13.new(" 7681900619016 ")
  expected = "7681900619016"
  assert_equal(expected, result)
end

- (Object) test_initialize3



31
32
33
34
35
# File 'test/test_model/ean13.rb', line 31

def test_initialize3
  assert_raises(SBSM::InvalidDataError) {
    ODDB::Ean13.new(" 768134871639 ")
  }
end

- (Object) test_new_unchecked



11
12
13
14
15
# File 'test/test_model/ean13.rb', line 11

def test_new_unchecked
  result = ODDB::Ean13.new_unchecked(" 768190061901 ")
  expected ="7681900619016"
  assert_equal(expected, result)
end

- (Object) test_new_unchecked2



16
17
18
19
20
# File 'test/test_model/ean13.rb', line 16

def test_new_unchecked2
  result = ODDB::Ean13.new_unchecked(" 76871639 ")
  expected ="7687163900007"
  assert_equal(expected, result)
end

- (Object) test_new_unchecked3



21
22
23
24
25
# File 'test/test_model/ean13.rb', line 21

def test_new_unchecked3
  assert_raises(SBSM::InvalidDataError) {
    ODDB::Ean13.new_unchecked(" 7687456789163 ")
  }
end

- (Object) test_valid



51
52
53
54
55
# File 'test/test_model/ean13.rb', line 51

def test_valid
  result = ODDB::Ean13.new("7681900619016")
  expected = "7681900619016"
  assert_equal(expected, result)  
end

- (Object) test_valid2



56
57
58
59
60
# File 'test/test_model/ean13.rb', line 56

def test_valid2
  assert_raises(SBSM::InvalidDataError) {
    ODDB::Ean13.new(" 7687456789163 ")
  }
end