Template:Test case/testcases
This is the template test case page for Template:Test case and its sandbox version. You may have to to update the examples.
Illustrating correct usage
These cases show how this template could be used to document proper use of the template {{Package}}.
The wikicode:
{{Test case |title=One unnamed parameter |<nowiki>{{Package|sys-apps/portage}}</nowiki> | {{Package|sys-apps/portage}} |{{Package/sandbox|sys-apps/portage}} }}
Results in:
{{Package|sys-apps/portage}}
Using the sandbox version (Test case/sandbox):
{{Test case/sandbox |title=One unnamed parameter |<nowiki>{{Package|sys-apps/portage}}</nowiki> | {{Package|sys-apps/portage}} |{{Package/sandbox|sys-apps/portage}} }}
Results in:
{{Package|sys-apps/portage}}
Illustrating incorrect usage
These cases show how this template could be used to document improper use of the template {{Package}}.
The wikicode:
{{Test case |title=No parameter |error=error message |<nowiki>{{Package}}</nowiki> | {{Package}} |{{Package/sandbox}} }}
Results in:
{{Package}}
1
parameter.1
parameter.Using the sandbox version (Test case/sandbox):
{{Test case/sandbox |title=No parameter |error=error message |<nowiki>{{Package}}</nowiki> | {{Package}} |{{Package/sandbox}} }}
Results in:
{{Package}}
1
parameter.1
parameter.Cases with multiline wikicode
Some templates are best illustrated with multiline sample wikicode (because that's how they are best used in practice). In such cases, the value of the first anonymous parameter will contain newlines. Here are some examples showing what this looks like. They show how the template {{InfoBox stack}} might be documented.
Notice how the newlines between the <nowiki> and </nowiki> tags have been turned into spaces in the resulting "Wiki code". This might be acceptable in some cases but not in others.
{{Clear}} is used here to fix formatting problems that arise when a test case involves right-floated content.
The wikicode:
{{Test case |title=One unnamed parameter |<nowiki>{{InfoBox stack | {{InfoBox homepage|http://www.samba.org|header=true}} }}</nowiki> |{{InfoBox stack | {{InfoBox homepage|http://www.samba.org|header=true}} }}{{Clear}} |{{InfoBox stack/sandbox | {{InfoBox homepage|http://www.samba.org|header=true}} }}{{Clear}} }}
Results in:
Using the sandbox version (Test case/sandbox):
{{Test case/sandbox |title=One unnamed parameter |<nowiki>{{InfoBox stack | {{InfoBox homepage|http://www.samba.org|header=true}} }}</nowiki> |{{InfoBox stack | {{InfoBox homepage|http://www.samba.org|header=true}} }}{{Clear}} |{{InfoBox stack/sandbox | {{InfoBox homepage|http://www.samba.org|header=true}} }}{{Clear}} }}
Results in:
Using code=pre
Newlines in the first anonymous parameter can be preserved if the code=pre
is used, as in the following example that is otherwise identical to the previous one.
Notice that the resulting "Wiki code" is shown as a block of preformatted text (because the usual <code> element has been turned into a <pre> element). This is generally preferable to having the newlines replaced by spaces.
The wikicode:
{{Test case |title=One unnamed parameter |code=pre |<nowiki>{{InfoBox stack | {{InfoBox homepage|http://www.samba.org|header=true}} }}</nowiki> |{{InfoBox stack | {{InfoBox homepage|http://www.samba.org|header=true}} }}{{Clear}} |{{InfoBox stack/sandbox | {{InfoBox homepage|http://www.samba.org|header=true}} }}{{Clear}} }}
Results in:
Using the sandbox version (Test case/sandbox):
{{Test case/sandbox |title=One unnamed parameter |code=pre |<nowiki>{{InfoBox stack | {{InfoBox homepage|http://www.samba.org|header=true}} }}</nowiki> |{{InfoBox stack | {{InfoBox homepage|http://www.samba.org|header=true}} }}{{Clear}} |{{InfoBox stack/sandbox | {{InfoBox homepage|http://www.samba.org|header=true}} }}{{Clear}} }}
Results in: