Xregistry

Check-in [8538d16488]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add tests for readBoolEntry, readRealEntry, writeBoolEntry, and writeRealEntry.
Timelines: family | ancestors | descendants | both | trunk | version-1.3.8
Files: files | file ages | folders
SHA1:8538d16488f0e99a56227c99079774531202e32f
User & Date: wbp 2016-02-21 03:32:39
Context
2016-02-22
16:53
Make corrections to gemspec and add additional tests. check-in: 083d4a0378 user: wbp tags: trunk, version-1.3.9
2016-02-21
03:32
Add tests for readBoolEntry, readRealEntry, writeBoolEntry, and writeRealEntry. check-in: 8538d16488 user: wbp tags: trunk, version-1.3.8
2016-02-18
18:18
Generate RDoc documentation. check-in: 2720babe78 user: wbp tags: trunk, version-1.3.7
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to VERSION.

1
1.3.7
|
1
1.3.8

Changes to test/test_xregistry.rb.

1
2
3
4
5
6
7
8
9
..
10
11
12
13
14
15
16












17
18
19
20
21
22






23
24
25
26
27
28











29
30
31
32
33
34
35







36
37
38
39
40
41
42
# test program for wregistry gem
# Last modified:  13-Feb-2016

require 'xregistry'
require 'test/unit'

class TestWregistry < Test::Unit::TestCase
  def setup
    @@reg ||= Registry.new('testxreg', 'Wikareia')
................................................................................
  end

  def test_new
    assert_equal(Registry, @@reg.class)
  rescue
    flunk "error encountered opening database: #{$!}"
  end













  # test of readIntEntry
  def test_read_int_entry
    value = @@reg.readIntEntry('Settings', 'int_key1', 123)
    assert_equal(123, value)
  end







  # test of readStringEntry
  def test_read_string_entry
    string = @@reg.readStringEntry('Settings', 'string_key1', 'default value')
    assert_match(/ value/, string)
  end












  # test of writeIntEntry
  def test_write_int_entry
    @@reg.writeIntEntry('Settings', 'int_key2', 456)
    value = @@reg.readIntEntry('Settings', 'int_key2', nil)
    assert_equal(456, value)
  end








  # test of writeStringEntry
  def test_write_string_entry
    @@reg.writeStringEntry('Settings', 'string_key2', 'test value')
    string = @@reg.readStringEntry('Settings', 'string_key2', nil)
    assert_equal('test value', string)
  end

|







 







>
>
>
>
>
>
>
>
>
>
>
>






>
>
>
>
>
>






>
>
>
>
>
>
>
>
>
>
>







>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
..
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# test program for wregistry gem
# Last modified:  20-Feb-2016

require 'xregistry'
require 'test/unit'

class TestWregistry < Test::Unit::TestCase
  def setup
    @@reg ||= Registry.new('testxreg', 'Wikareia')
................................................................................
  end

  def test_new
    assert_equal(Registry, @@reg.class)
  rescue
    flunk "error encountered opening database: #{$!}"
  end

  # test of readBoolEntry
  def test_read_bool_entry
    value = @@reg.readBoolEntry('Settings', 'bool_key1')
    assert_equal(false, value)

    value = @@reg.readBoolEntry('Settings', 'bool_key1', true)
    assert_equal(true, value)

    value = @@reg.readBoolEntry('Settings', 'bool_key1', false)
    assert_equal(false, value)
  end

  # test of readIntEntry
  def test_read_int_entry
    value = @@reg.readIntEntry('Settings', 'int_key1', 123)
    assert_equal(123, value)
  end

  # test of readRealEntry
  def test_read_real_entry
    value = @@reg.readRealEntry('Settings', 'real_key1', 12.5)
    assert_equal(12.5, value)
  end

  # test of readStringEntry
  def test_read_string_entry
    string = @@reg.readStringEntry('Settings', 'string_key1', 'default value')
    assert_match(/ value/, string)
  end

  # test of writeBoolEntry
  def test_write_bool_entry
    @@reg.writeBoolEntry('Settings', 'bool_key2', true)
    value = @@reg.readBoolEntry('Settings', 'bool_key2', nil)
    assert_equal(true, value)

    @@reg.writeBoolEntry('Settings', 'bool_key2', false)
    value = @@reg.readBoolEntry('Settings', 'bool_key2', nil)
    assert_equal(false, value)
  end

  # test of writeIntEntry
  def test_write_int_entry
    @@reg.writeIntEntry('Settings', 'int_key2', 456)
    value = @@reg.readIntEntry('Settings', 'int_key2', nil)
    assert_equal(456, value)
  end

  # test of writeRealEntry
  def test_write_real_entry
    @@reg.writeRealEntry('Settings', 'real_key2', 25.5)
    value = @@reg.readRealEntry('Settings', 'real_key2', nil)
    assert_equal(25.5, value)
  end

  # test of writeStringEntry
  def test_write_string_entry
    @@reg.writeStringEntry('Settings', 'string_key2', 'test value')
    string = @@reg.readStringEntry('Settings', 'string_key2', nil)
    assert_equal('test value', string)
  end