aboutsummaryrefslogtreecommitdiff
path: root/grit/format/rc_header_unittest.py
diff options
context:
space:
mode:
Diffstat (limited to 'grit/format/rc_header_unittest.py')
-rw-r--r--grit/format/rc_header_unittest.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/grit/format/rc_header_unittest.py b/grit/format/rc_header_unittest.py
index 433ff7d..dccead1 100644
--- a/grit/format/rc_header_unittest.py
+++ b/grit/format/rc_header_unittest.py
@@ -154,6 +154,40 @@ class RcHeaderFormatterUnittest(unittest.TestCase):
output = util.StripBlankLinesAndComments(output)
self.assertEqual('#pragma once\nBingo', output)
+ def testRcHeaderFormat(self):
+ grd = grd_reader.Parse(StringIO.StringIO('''<?xml version="1.0" encoding="UTF-8"?>
+ <grit latest_public_release="2" source_lang_id="en" current_release="3" base_dir=".">
+ <release seq="3">
+ <includes first_id="300" comment="bingo">
+ <include type="gif" name="IDR_LOGO" file="images/logo.gif" />
+ </includes>
+ <messages first_id="10000">
+ <message name="IDS_GREETING" desc="Printed to greet the currently logged in user">
+ Hello <ph name="USERNAME">%s<ex>Joi</ex></ph>, how are you doing today?
+ </message>
+ <message name="IDS_BONGO">
+ Bongo!
+ </message>
+ </messages>
+ </release>
+ </grit>'''), '.')
+
+ # Using the default rc_header format string.
+ output = rc_header.FormatDefines(grd, grd.ShouldOutputAllResourceDefines(),
+ grd.GetRcHeaderFormat())
+ self.assertEqual(('#define IDR_LOGO 300\n'
+ '#define IDS_GREETING 10000\n'
+ '#define IDS_BONGO 10001\n'), ''.join(output))
+
+ # Using a custom rc_header format string.
+ grd.AssignRcHeaderFormat(
+ '#define {textual_id} _Pragma("{textual_id}") {numeric_id}\n')
+ output = rc_header.FormatDefines(grd, grd.ShouldOutputAllResourceDefines(),
+ grd.GetRcHeaderFormat())
+ self.assertEqual(('#define IDR_LOGO _Pragma("IDR_LOGO") 300\n'
+ '#define IDS_GREETING _Pragma("IDS_GREETING") 10000\n'
+ '#define IDS_BONGO _Pragma("IDS_BONGO") 10001\n'),
+ ''.join(output))
if __name__ == '__main__':
unittest.main()