1. dimajix
  2. Untitled project
  3. Magnum

Source

Magnum / source / libs / magnum_net / unittest / Test_MediaType.h

/*
  Magnum
  Copyright (C) 2002-2011 Kaya Kupferschmidt. All Rights Reserved.

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, under the terms in LICENSE.TXT.

  Kaya Kupferschmidt  (k.kupferschmidt@dimajix.de)
*/

#include "magnum/system.h"
#include "magnum/test.h"
#include "magnum/net/MediaType.h"


using namespace magnum::net;
using namespace magnum::io;
using magnum::types::String;


class Test_MediaType : public magnum::test::StdTestSuite {
public:

void test_empty(void)
{
    MediaType empty;
    TEST_ASSERT( empty.isEmpty() );
    TEST_ASSERT( !empty.isValid() );
    TEST_ASSERT( empty.getType() == "" );
    TEST_ASSERT( empty.getSubtype() == "" );
    TEST_ASSERT( empty.toString() == "" );
}


void test_simple(void)
{
    MediaType mt("type/subtype");
    TEST_ASSERT( !mt.isEmpty() );
    TEST_ASSERT( mt.isValid() );
    TEST_ASSERT( mt.getType() == "type" );
    TEST_ASSERT( mt.getSubtype() == "subtype" );
    TEST_ASSERT( mt.toString() == "type/subtype" );
}


void test_parser(void)
{
    MediaType mt("type","subtype");
    TEST_ASSERT( !mt.isEmpty() );
    TEST_ASSERT( mt.isValid() );
    TEST_ASSERT( mt.getType() == "type" );
    TEST_ASSERT( mt.getSubtype() == "subtype" );
    TEST_ASSERT( mt.toString() == "type/subtype" );
}


Test_MediaType()
{
    TEST_ADD( Test_MediaType::test_empty );
    TEST_ADD( Test_MediaType::test_simple );
    TEST_ADD( Test_MediaType::test_parser );
}
};