Difference between revisions of "WikiDB/Data type unit tests"
From TestWiki
< WikiDB
(Changed Example.jpg to an image that actually exists, to give more meaningful output. Also updated image: to file: for the direct image link, to reflect what it should be.) |
(Changed intro; Fixed a test that is no longer correct.) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | This page is for unit-testing the GuessType() function, and the FormatAsType() function. WikiDB provides a <code><guesstypes></code> tag to enable this testing. This page is not intended for public consumption, but for my own internal testing, | + | This page is for unit-testing the GuessType() function, and the FormatAsType() function. WikiDB provides a <code><guesstypes></code> tag to enable this testing. This page is not intended for public consumption, but for my own internal testing. However, feel free to snoop! |
+ | |||
+ | Note that WikiDB now includes [[WikiDB/Unit testing|proper unit tests]], which can be run using the MediaWiki unit testing framework, and which cover all of the tests on this page, and more. However, I have left the page in place as a quick visual check, covering some common edge-cases, for situations where I don't want the overhead of running the tests. | ||
== Strings == | == Strings == | ||
Line 7: | Line 9: | ||
Basic text: I want to be a lumberjack! | Basic text: I want to be a lumberjack! | ||
=wikistring:I want to be a lumberjack! | =wikistring:I want to be a lumberjack! | ||
+ | UTF8-Text:This Be œæ••±‘‘’Æ∏؈flıflN" | ||
+ | =wikistring:This Be œæ••±‘‘’Æ∏؈flıflN" | ||
</guesstypes> | </guesstypes> | ||
Line 20: | Line 24: | ||
=number:5.0 | =number:5.0 | ||
Longer real number: 1245.32452 | Longer real number: 1245.32452 | ||
− | =number: | + | =number:1,245.32452 |
Zero as real number: 0.0 | Zero as real number: 0.0 | ||
=number:0.0 | =number:0.0 | ||
Negative real number: -2343.981 | Negative real number: -2343.981 | ||
− | =number:- | + | =number:-2,343.981 |
Real number without integer component: .43 | Real number without integer component: .43 | ||
=number:0.43 | =number:0.43 | ||
Real number without decimal component: 3. | Real number without decimal component: 3. | ||
− | = | + | =wikistring:3. |
Number with more than one decimal point: 1.2.3 | Number with more than one decimal point: 1.2.3 | ||
=wikistring:1.2.3 | =wikistring:1.2.3 | ||
Line 48: | Line 52: | ||
=number:34.35 | =number:34.35 | ||
Leading & traling: 00009938.43800000 | Leading & traling: 00009938.43800000 | ||
− | =number: | + | =number:9,938.438 |
Example from documentation #1: 808 | Example from documentation #1: 808 | ||
=integer:808 | =integer:808 | ||
Line 62: | Line 66: | ||
=Link:[[Main Page]] | =Link:[[Main Page]] | ||
Image: [[Image:WikiDB icon.png]] | Image: [[Image:WikiDB icon.png]] | ||
− | =IMAGE:[[File: | + | =IMAGE:[[File:WikiDB_icon.png|75px|]] |
Link to image: [[:Image:WikiDB icon.png]] | Link to image: [[:Image:WikiDB icon.png]] | ||
=link:[[:Image:WikiDB icon.png]] | =link:[[:Image:WikiDB icon.png]] |
Latest revision as of 22:37, 30 March 2019
This page is for unit-testing the GuessType() function, and the FormatAsType() function. WikiDB provides a <guesstypes>
tag to enable this testing. This page is not intended for public consumption, but for my own internal testing. However, feel free to snoop!
Note that WikiDB now includes proper unit tests, which can be run using the MediaWiki unit testing framework, and which cover all of the tests on this page, and more. However, I have left the page in place as a quick visual check, covering some common edge-cases, for situations where I don't want the overhead of running the tests.
Strings[edit]
Description | Original value | Type | Typed value | Formatted for sorting Spaces are currently collapsed, for ease of reading. Check source for full string. |
||
---|---|---|---|---|---|---|
Unrendered | Rendered | Unrendered | Rendered | |||
Empty string | wikistring | [ ] |
||||
Basic text | I want to be a lumberjack! | I want to be a lumberjack! | wikistring | I want to be a lumberjack! | I want to be a lumberjack! | [I want to be a lumberjack! ] |
UTF8-Text | This Be œæ••±‘‘’Æ∏؈flıflN" | This Be œæ••±‘‘’Æ∏؈flıflN" | wikistring | This Be œæ••±‘‘’Æ∏؈flıflN" | This Be œæ••±‘‘’Æ∏؈flıflN" | [This Be œæ••±‘‘’Æ∏؈flıflN" ] |
Numbers[edit]
Description | Original value | Type | Typed value | Formatted for sorting Spaces are currently collapsed, for ease of reading. Check source for full string. |
||
---|---|---|---|---|---|---|
Unrendered | Rendered | Unrendered | Rendered | |||
Zero | 0 | 0 | integer | 0 | 0 | [ p 0.0 ] |
Integer | 34 | 34 | integer | 34 | 34 | [ p 34.0 ] |
Negative integer | -21 | -21 | integer | -21 | -21 | [ n 21.0 ] |
Real number | 5.0 | 5.0 | number | 5.0 | 5.0 | [ p 5.0 ] |
Longer real number | 1245.32452 | 1245.32452 | number | 1,245.32452 | 1,245.32452 | [ p 1245.32452 ] |
Zero as real number | 0.0 | 0.0 | number | 0.0 | 0.0 | [ p 0.0 ] |
Negative real number | -2343.981 | -2343.981 | number | -2,343.981 | -2,343.981 | [ n 2343.981 ] |
Real number without integer component | .43 | .43 | number | 0.43 | 0.43 | [ p 0.43 ] |
Real number without decimal component | 3. | 3. | wikistring | 3. | 3. | [3. ] |
Number with more than one decimal point | 1.2.3 | 1.2.3 | wikistring | 1.2.3 | 1.2.3 | [1.2.3 ] |
String followed by number | catch 22 | catch 22 | wikistring | catch 22 | catch 22 | [catch 22 ] |
Number followed by string | 39 steps | 39 steps | wikistring | 39 steps | 39 steps | [39 steps ] |
Number wrapped in text | measure 4 measure | measure 4 measure | wikistring | measure 4 measure | measure 4 measure | [measure 4 measure ] |
Numbers separated by spaces | 1 2 3 | 1 2 3 | wikistring | 1 2 3 | 1 2 3 | [1 2 3 ] |
Numbers separated by commas | 1,2,3 | 1,2,3 | wikistring | 1,2,3 | 1,2,3 | [1,2,3 ] |
Leading zeros | 0005.4 | 0005.4 | number | 5.4 | 5.4 | [ p 5.4 ] |
Leading zeros (integer) | 00035 | 00035 | integer | 35 | 35 | [ p 35.0 ] |
Trailing zeros | 34.350000 | 34.350000 | number | 34.35 | 34.35 | [ p 34.35 ] |
Leading & traling | 00009938.43800000 | 00009938.43800000 | number | 9,938.438 | 9,938.438 | [ p 9938.438 ] |
Example from documentation #1 | 808 | 808 | integer | 808 | 808 | [ p 808.0 ] |
Example from documentation #2 | 808 State | 808 State | wikistring | 808 State | 808 State | [808 State ] |
Links[edit]
Description | Original value | Type | Typed value | Formatted for sorting Spaces are currently collapsed, for ease of reading. Check source for full string. |
||
---|---|---|---|---|---|---|
Unrendered | Rendered | Unrendered | Rendered | |||
Wiki link without brackets | Help:About | Help:About | wikistring | Help:About | Help:About | [Help:About ] |
Link to main namespace | [[Main Page]] | Main Page | link | [[Main Page]] | Main Page | [Main_Page ] |
Image | [[Image:WikiDB icon.png]] | image | [[File:WikiDB_icon.png|75px|]] | [File:WikiDB_icon.png ] |
||
Link to image | [[:Image:WikiDB icon.png]] | Image:WikiDB icon.png | link | [[:Image:WikiDB icon.png]] | Image:WikiDB icon.png | [File:WikiDB_icon.png ] |
Category | [[category:New category]] | link | [[:category:New category]] | category:New category | [Category:New_category ] |
|
Link to category | [[:category:New category]] | category:New category | link | [[:category:New category]] | category:New category | [Category:New_category ] |
Link to template namespace | [[Template:New template]] | Template:New template | link | [[Template:New template]] | Template:New template | [Template:New_template ] |
Link to mediawiki namespace | [[MediaWiki:mainpage]] | MediaWiki:mainpage | link | [[MediaWiki:mainpage]] | MediaWiki:mainpage | [MediaWiki:Mainpage ] |
Link with pipe | [[Main Page|link to the main page]] | link to the main page | link | [[Main Page|link to the main page]] | link to the main page | [Main_Page ] |
URL without tags | http://www.kennel17.co.uk | http://www.kennel17.co.uk | wikistring | http://www.kennel17.co.uk | http://www.kennel17.co.uk | [http://www.kennel17.co.uk ] |
URL in tags | [http://www.kennel17.co.uk] | [1] | wikistring | [http://www.kennel17.co.uk] | [2] | [[http://www.kennel17.co.uk] ] |
URL with description | [http://www.kennel17.co.uk Kennel 17] | Kennel 17 | wikistring | [http://www.kennel17.co.uk Kennel 17] | Kennel 17 | [[http://www.kennel17.co.uk Kennel 17] ] |