nsc: add CUnit test.

This commit is contained in:
Vic Lee 2012-03-06 18:55:54 +08:00
parent d2153e9ef2
commit 35555856ec
4 changed files with 113 additions and 0 deletions

View File

@ -62,6 +62,8 @@ add_executable(test_freerdp
test_drdynvc.h
test_rfx.c
test_rfx.h
test_nsc.c
test_nsc.h
test_sspi.c
test_sspi.h
test_freerdp.c

View File

@ -37,6 +37,7 @@
#include "test_cliprdr.h"
#include "test_drdynvc.h"
#include "test_rfx.h"
#include "test_nsc.h"
#include "test_freerdp.h"
#include "test_rail.h"
#include "test_pcap.h"
@ -138,6 +139,7 @@ static test_suite suites[] =
{ "per", add_per_suite },
{ "rail", add_rail_suite },
{ "rfx", add_rfx_suite },
{ "nsc", add_nsc_suite },
{ "sspi", add_sspi_suite },
{ "stream", add_stream_suite },
{ "utils", add_utils_suite },

82
cunit/test_nsc.c Normal file
View File

@ -0,0 +1,82 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* NSCodec Library Unit Tests
*
* Copyright 2012 Vic Lee
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* The sample data comes from [MS-RDPRFX] 4.2.3, which is decoded into three
* vertical bands in red (21x64), green (23x64) and blue(20x64) color.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <freerdp/types.h>
#include <freerdp/utils/print.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/hexdump.h>
#include <freerdp/codec/nsc.h>
#include "test_nsc.h"
static const uint8 nsc_data[] =
{
0x71, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
0x03, 0x01, 0x00, 0x00, 0x63, 0x63, 0x01, 0x64, 0x64, 0x00, 0x63, 0x63, 0x02, 0x64, 0x64, 0x00,
0x63, 0x63, 0x00, 0x64, 0x64, 0x01, 0x63, 0x63, 0x01, 0x64, 0x64, 0x01, 0x63, 0x63, 0x01, 0x64,
0x64, 0x00, 0x63, 0x63, 0x00, 0x64, 0x64, 0x01, 0x63, 0x63, 0x00, 0x64, 0x64, 0x0c, 0x63, 0x63,
0x00, 0x64, 0x64, 0x0c, 0x63, 0x63, 0x00, 0x64, 0x64, 0x0c, 0x63, 0x63, 0x00, 0x64, 0x64, 0x0c,
0x63, 0x64, 0x64, 0x04, 0x63, 0x64, 0x63, 0x63, 0x00, 0x64, 0x64, 0x03, 0x63, 0x64, 0x64, 0x03,
0x63, 0x63, 0x00, 0x64, 0x63, 0x63, 0x00, 0x64, 0x64, 0x03, 0x65, 0x63, 0x64, 0x64, 0x01, 0x63,
0x64, 0x64, 0x00, 0x65, 0x64, 0x64, 0x06, 0x63, 0x64, 0x64, 0x00, 0x63, 0x63, 0x00, 0x64, 0x64,
0x04, 0x64, 0x65, 0x65, 0x65, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x37, 0x37, 0x19, 0x36,
0x37, 0x37, 0x06, 0x37, 0x37, 0x37, 0x37, 0xff, 0xff, 0x90, 0xff, 0xff, 0xff, 0xff
};
int init_nsc_suite(void)
{
return 0;
}
int clean_nsc_suite(void)
{
return 0;
}
int add_nsc_suite(void)
{
add_test_suite(nsc);
add_test_function(nsc_decode);
add_test_function(nsc_encode);
return 0;
}
void test_nsc_decode(void)
{
NSC_CONTEXT* context;
context = nsc_context_new();
nsc_process_message(context, 32, 15, 10, (uint8*) nsc_data, sizeof(nsc_data));
/*freerdp_hexdump(context->bmpdata, 15 * 10 * 4);*/
nsc_context_free(context);
}
void test_nsc_encode(void)
{
}

27
cunit/test_nsc.h Normal file
View File

@ -0,0 +1,27 @@
/**
* FreeRDP: A Remote Desktop Protocol Client
* NSCodec Library Unit Tests
*
* Copyright 2012 Vic Lee
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "test_freerdp.h"
int init_nsc_suite(void);
int clean_nsc_suite(void);
int add_nsc_suite(void);
void test_nsc_decode(void);
void test_nsc_encode(void);