Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for a tool to quickly test C# format strings [closed]

I am constantly forgetting what the special little codes are for formatting .NET strings. Either through ToString() or using String.Format(). Alignment, padding, month vs. minute (month is uppercase M?), abbreviation vs. full word, etc. I can never remember.

I have the same problem with regexes, but luckily there's Expresso to help me out. It's awesome.

Is there a tool like Expresso for experimenting with formatted strings on standard types like DateTime and float and so on?

like image 259
scobi Avatar asked Jan 09 '09 00:01

scobi


People also ask

What is the tool used for to check test coverage?

Qase. Qase is also a cloud computing-based project management tool, which works excellently for determining the Test Coverage periodically identified for the Test Management process.

Can I use Gtest for C?

It is pretty common to test C code using a C++ testing frameworks, even the leading book on the subject follows this approach. I have used googletest extensively in the past to unit test C code and can recommend it.

What are unit tests C?

A Unit Testing Framework for C CUnit is a lightweight system for writing, administering, and running unit tests in C. It provides C programmers a basic testing functionality with a flexible variety of user interfaces. CUnit is built as a static library which is linked with the user's testing code.


1 Answers

PowerShell works great for testing format strings. From PowerShell you can load your assembly and work with the objects and methods you want to test. You could also just create a string on the command line and test out different formatting options.

You can use the static method from the string class:

$teststring = 'Currency - {0:c}.  And a date - {1:ddd d MMM}.  And a plain string - {2}'
[string]::Format($teststring, 160.45, Get-Date, 'Test String')

Or PowerShell has a built in format operator

$teststring = 'Currency - {0:c}.  And a date - {1:ddd d MMM}.  And a plain string - {2}'
$teststring -f 160.45, Get-Date, 'Test String'
like image 142
Steven Murawski Avatar answered Nov 15 '22 11:11

Steven Murawski