Bug 468575 - Scrape some gunk off the config/ grout, r=ted
[wine-gecko.git] / intl / strres / tests / unit / test_bug378839.js
blobbfcd41f9caf5b71b92a82e110c8171cff4d2459e
1 /* Tests getting properties from string bundles
2  */
4 const name_file = "file";
5 const value_file = "File";
7 const name_loyal = "loyal";
8 const value_loyal = "\u5fe0\u5fc3"; // tests escaped Unicode
10 const name_trout = "trout";
11 const value_trout = "\u9cdf\u9b5a"; // tests UTF-8
13 const name_edit = "edit";
14 const value_edit = "Edit"; // tests literal leading spaces are stripped
16 const name_view = "view";
17 const value_view = "View"; // tests literal trailing spaces are stripped
19 const name_go = "go";
20 const value_go = " Go"; // tests escaped leading spaces are not stripped
22 const name_message = "message";
23 const value_message = "Message "; // tests escaped trailing spaces are not stripped
25 const name_hello = "hello";
26 const var_hello = "World";
27 const value_hello = "Hello World"; // tests formatStringFromName with parameter
30 function run_test() {
31     var StringBundle = 
32         Components.classes["@mozilla.org/intl/stringbundle;1"]
33          .getService(Components.interfaces.nsIStringBundleService);
35     var bundle = StringBundle.createBundle("resource://gre/res/strres.properties");
37     var bundle_file = bundle.GetStringFromName(name_file);
38     do_check_eq(bundle_file, value_file);
40     var bundle_loyal = bundle.GetStringFromName(name_loyal);
41     do_check_eq(bundle_loyal, value_loyal);
43     var bundle_trout = bundle.GetStringFromName(name_trout);
44     do_check_eq(bundle_trout, value_trout);
46     var bundle_edit = bundle.GetStringFromName(name_edit);
47     do_check_eq(bundle_edit, value_edit);
49     var bundle_view = bundle.GetStringFromName(name_view);
50     do_check_eq(bundle_view, value_view);
52     var bundle_go = bundle.GetStringFromName(name_go);
53     do_check_eq(bundle_go, value_go);
55     var bundle_message = bundle.GetStringFromName(name_message);
56     do_check_eq(bundle_message, value_message);
58     var bundle_hello = bundle.formatStringFromName(name_hello, [var_hello], 1);
59     do_check_eq(bundle_hello, value_hello);
61