Xregistry

Check-in [7aec519c28]
Login

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

Overview
Comment:Raise error in readBoolEntry if value retrieved is a float.
Timelines: family | ancestors | descendants | both | trunk | version-1.5.2
Files: files | file ages | folders
SHA1:7aec519c2883a14f90377517d85365abd4bcba26
User & Date: wbp 2016-03-20 01:17:12
Context
2016-08-01
21:43
Make separate "userinstall" target to Rakefile. check-in: efa5af7568 user: wbp tags: trunk
2016-03-20
01:17
Raise error in readBoolEntry if value retrieved is a float. check-in: 7aec519c28 user: wbp tags: trunk, version-1.5.2
2016-03-19
21:15
Raise error in readBoolEntry if value is a string and add additional tests of reading entries. check-in: 024e690d87 user: wbp tags: trunk, version-1.5.1
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to VERSION.

1
1.5.1
|
1
1.5.2

Changes to lib/xregistry.rb.

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
      @db.execute "drop table if exists \"#{section}\""
    end
  end
  alias delete_section deleteSection

  # Read a boolean registry entry from the specified section and key.  If no
  # value is found, the default value is returned.  A type error is
  # raised if the retrieved value is a string.
  def readBoolEntry(section, key, default = false)
    value = readEntry(section, key, default)
    raise TypeError if value.class == String
    value && value != 0
  end
  alias read_bool_entry readBoolEntry

  # Read an integer registry entry from the specified section and key.  If no
  # value is found, the default value is returned.
  def readIntEntry(section, key, default = 0)







|


|







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
      @db.execute "drop table if exists \"#{section}\""
    end
  end
  alias delete_section deleteSection

  # Read a boolean registry entry from the specified section and key.  If no
  # value is found, the default value is returned.  A type error is
  # raised if the retrieved value is real or a string.
  def readBoolEntry(section, key, default = false)
    value = readEntry(section, key, default)
    raise TypeError if value.class == Float || value.class == String
    value && value != 0
  end
  alias read_bool_entry readBoolEntry

  # Read an integer registry entry from the specified section and key.  If no
  # value is found, the default value is returned.
  def readIntEntry(section, key, default = 0)

Changes to test/test_xregistry.rb.

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    assert_equal(false, value)

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

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

    @@reg.writeStringEntry('Settings', 'bool_key1', '2')
    assert_raise(TypeError) { @@reg.readBoolEntry('Settings', 'bool_key1') }
  end

  # test of readIntEntry
  def test_read_int_entry







|
<







30
31
32
33
34
35
36
37

38
39
40
41
42
43
44
    assert_equal(false, value)

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

    @@reg.writeRealEntry('Settings', 'bool_key1', 2.5)
    assert_raise(TypeError) { @@reg.readBoolEntry('Settings', 'bool_key1') }


    @@reg.writeStringEntry('Settings', 'bool_key1', '2')
    assert_raise(TypeError) { @@reg.readBoolEntry('Settings', 'bool_key1') }
  end

  # test of readIntEntry
  def test_read_int_entry