Template:Test case/testcases

From Gentoo Wiki
Jump to:navigation Jump to:search
Note
This is the template test case page for Template:Test case and its sandbox version. You may have to purge this page 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:

One unnamed parameter
Wiki code
{{Package|sys-apps/portage}}
Main version
Sandbox version

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:

One unnamed parameter
Wiki code
{{Package|sys-apps/portage}}
Main version
Sandbox version

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:

No parameter (error message)
Wiki code
{{Package}}
Main version
{{Package template error}}
Parameter 1 not defined. For correct usage see Package template's documentation on the 1 parameter.
Sandbox version
{{Package template error}}
Parameter 1 not defined. For correct usage see Package template's documentation on the 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:

No parameter (error message)
Wiki code
{{Package}}
Main version
{{Package template error}}
Parameter 1 not defined. For correct usage see Package template's documentation on the 1 parameter.
Sandbox version
{{Package template error}}
Parameter 1 not defined. For correct usage see Package template's documentation on the 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:

One unnamed parameter
Wiki code
{{InfoBox stack | {{InfoBox homepage|http://www.samba.org|header=true}} }}
Main version
Resources
Sandbox version
Resources

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:

One unnamed parameter
Wiki code
{{InfoBox stack | {{InfoBox homepage|http://www.samba.org|header=true}} }}
Main version
Resources
Sandbox version
Resources

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:

One unnamed parameter
Wiki code
{{InfoBox stack
| {{InfoBox homepage|http://www.samba.org|header=true}}
}}
Main version
Resources
Sandbox version
Resources

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:

One unnamed parameter
Wiki code
{{InfoBox stack
| {{InfoBox homepage|http://www.samba.org|header=true}}
}}
Main version
Resources
Sandbox version
Resources