Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

The Mini Shell Extension Framework – Part III

By , 18 Sep 2005
msf091.zip
include
columnprovider.rgs
contextmenu.rgs
contextmenu_sf.rgs
extension.rgs
extractimage_sf.rgs
infotip.rgs
infotip_sf.rgs
propertysheetext.rgs
propertysheetext_sf.rgs
shell32missing.def
shell32missing.lib
shellfolder.rgs
shellfolderwin98.rgs
vvvsample
Copy of sample1.vvv
menuicon.bmp
sample.def
sample.manifest
sample1.vvv
vvv.ico
vvvtest
sample.yyy
sample1.vvv
sample2.vvv
//
// (C) Copyright by Victor Derks <vba64@xs4all.nl>
//
// See README.TXT for the details of the software licence.
//
#pragma once


#include <conio.h>  // for _getch
#include <stdlib.h> // for EXIT_SUCCESS / EXIT_FAILURE
#include <iostream>


namespace MSF
{

typedef void (*performtest_fn)();

#ifdef UNICODE
#define tcout wcout
#else
#define tcout cout
#endif

struct test_t
{
	const TCHAR*   szName;
	performtest_fn PerformTest;
};


class CTestRunner
{
public:
	static int Main(const test_t* ptests, unsigned int nTests, int argc, _TCHAR* argv[])
	{
		CTestRunner testrunner(ptests, nTests);

		return testrunner.Main(argc, argv);
	}


	CTestRunner(const test_t* ptests, unsigned int nTests) :
		_ptests(ptests), _nTests(nTests)
	{
	}


	int Main(int argc, _TCHAR* argv[])
	{
		bool bWaitForKeypress = true;

		switch (argc)
		{
		case 1:
			PerformAllTests();
			break;

		case 2:
			PerformTest(argv[1]);
			break;

		case 3:
			{
				bWaitForKeypress = false;
				int nLoop = 0;
				_stscanf(argv[2], _T("%d"), &nLoop);
				for (int i = 0; i < nLoop; ++i)
				{
					PerformTest(argv[1]);
				}
			}
			break;

		default:
			std::tcout << _T("command line option unknown") << std::endl;
			return EXIT_FAILURE;
		}

		std::tcout << _T("\nAll test(s) completed, press any key to quit") << std::endl;

		if (bWaitForKeypress)
			_getch();

		return EXIT_SUCCESS;
	}


private:
	void PerformTest(const test_t& test)
	{
		std::tcout << _T("Performing test: ") << test.szName;
		try
		{
			test.PerformTest();
			std::tcout << _T(" -> OK") << std::endl;
		}
		catch (...)
		{
			std::tcout << _T(" -> Failed") << std::endl;
		}
	}


	void PerformTest(const TCHAR* szName)
	{
		for (unsigned int i = 0; i < _nTests; ++i)
		{
			if (_tcscmp(_ptests[i].szName, szName) == 0)
			{
				PerformTest(_ptests[i]);
				return;
			}
		}

		std::tcout << _T("Test ") << szName << _T(" Not found") << std::endl;
	}


	void PerformAllTests()
	{
		for (unsigned int i = 0; i < _nTests; ++i)
		{
			PerformTest(_ptests[i]);
		}
	}


	const test_t*  _ptests;
	unsigned int   _nTests;
};


// cleanup defined preprocessor macros
#undef tcout


} // end MSF namespace.

By viewing downloads associated with this article you agree to the Terms of use and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Victor Derks
Architect GE Healthcare
Netherlands Netherlands
Victor lives in Nijmegen, the oldest city in The Netherlands.
He studied Applied Physics in Delft and now works for GE Healthcare.

| Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 18 Sep 2005
Article Copyright 2005 by Victor Derks
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid