mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-30 20:07:36 +00:00
Test: added unit test CPBundleTest
This commit is contained in:
1 parent
eb4780a952
commit
66b1d297ba
3 files changed
+90
No files matched your search
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Main cib file base name</key>
|
||||
<string>MainMenu.cib</string>
|
||||
<key>CPBundleName</key>
|
||||
<string>BundleTest</string>
|
||||
<key>CPBundleLocalizableStrings</key>
|
||||
<array>
|
||||
<string>Localizable.strings</string>
|
||||
</array>
|
||||
<key>CPBundleDefaultLanguage</key>
|
||||
<string>fr</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,5 @@
|
||||
/* My first context. */
|
||||
"Label from file" = "Label traduit de fr.lproj du premier context";
|
||||
|
||||
/* My second context. */
|
||||
"Label from file" = "Label traduit de fr.lproj du second context";
|
||||
@@ -0,0 +1,69 @@
|
||||
@import <Foundation/CPBundle.j>
|
||||
|
||||
@implementation CPBundleTest : OJTestCase
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
+ (void)setUp
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
+ (void)tearDown
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)testCreationMainBundle
|
||||
{
|
||||
var bundle = [CPBundle mainBundle];
|
||||
}
|
||||
|
||||
- (void)testLoadingBundle
|
||||
{
|
||||
var bundle = [CPBundle bundleWithPath:@"Tests/Foundation/BundleTest"];
|
||||
[bundle loadWithDelegate:self];
|
||||
|
||||
[self assert:[bundle objectForInfoDictionaryKey:"CPBundleDefaultLanguage"] equals:"fr"];
|
||||
[self assert:[bundle objectForInfoDictionaryKey:"CPBundleLocalizableStrings"] equals:["Localizable.strings"]];
|
||||
}
|
||||
|
||||
- (void)testLocalization
|
||||
{
|
||||
var bundle = [CPBundle bundleWithPath:@"Tests/Foundation/BundleTest"];
|
||||
[bundle loadWithDelegate:self];
|
||||
|
||||
[self assert:[bundle localizedStringForKey:"Label from file" value:"" table:"Localizable"] equals:"Label traduit de fr.lproj du premier context"];
|
||||
[self assert:[bundle localizedStringForKey:"Wrong key" value:"Default value" table:"Localizable"] equals:"Default value"];
|
||||
[self assert:[bundle localizedStringForKey:"Wrong key" value:"" table:"Localizable"] equals:"Wrong key"];
|
||||
|
||||
[self assert:CPCopyLocalizedStringFromTableInBundle("Label from file", "Localizable", bundle, "My first context.") equals:"Label traduit de fr.lproj du premier context"];
|
||||
[self assert:CPCopyLocalizedStringFromTableInBundle("Label from file", "", bundle, "My first context.") equals:"Label traduit de fr.lproj du premier context"];
|
||||
[self assert:CPCopyLocalizedStringFromTableInBundle("Label from file", "Localizable", bundle, "") equals:"Label traduit de fr.lproj du premier context"];
|
||||
[self assert:CPCopyLocalizedStringFromTableInBundle("Wrong key", "Localizable", bundle, "") equals:"Wrong key"];
|
||||
[self assert:CPCopyLocalizedStringFromTableInBundle("Wrong key", "coucou", bundle, "") equals:"Wrong key"];
|
||||
|
||||
[self assert:CPCopyLocalizedStringFromTableInBundle("Label from file", "Localizable", bundle, "My second context.") equals:"Label traduit de fr.lproj du second context"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPBundleTest (CPBundleTestBundleDelegate)
|
||||
|
||||
- (void)bundleDidFinishLoading:(CPBundle)aBundle
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user