static void test_decoding(IDirectXVideoDecoder *decoder, REFGUID const guid, IDirect3DSurface9 **surfaces) { HRESULT hr; hr = IDirectXVideoDecoder_BeginFrame(decoder, surfaces[0], NULL); ok(!hr, "Failed to begin frame for: %s\n", convert_decoderguid_to_str(guid)); if (hr) return; test_buffer(decoder, DXVA2_PictureParametersBufferType, "DXVA2_PictureParametersBuffer"); test_buffer(decoder, DXVA2_InverseQuantizationMatrixBufferType, "DXVA2_InverseQuantizationMatrixBuffer"); test_buffer(decoder, DXVA2_SliceControlBufferType, "DXVA2_SliceControlBuffer"); test_buffer(decoder, DXVA2_BitStreamDateBufferType, "DXVA2_BitStreamDateBuffer"); IDirectXVideoDecoder_EndFrame(decoder, NULL); }
gint main (gint argc, gchar **argv) { GeglBuffer *buffer, *buffer2; GeglNode *gegl, *sink; gint i; gegl_init (&argc, &argv); buffer = test_buffer (1024, 1024, babl_format ("RGBA float")); #define ITERATIONS 8 test_start (); for (i=0;i< ITERATIONS;i++) gegl = gegl_graph (sink = gegl_node ("gegl:buffer-sink", "buffer", &buffer2, NULL, gegl_node ("gegl:brightness-contrast", "contrast", 0.2, NULL, gegl_node ("gegl:brightness-contrast", "contrast", 0.2, NULL, gegl_node ("gegl:brightness-contrast", "contrast", 0.2, NULL, gegl_node ("gegl:brightness-contrast", "contrast", 1.2, NULL, gegl_node ("gegl:buffer-source", "buffer", buffer, NULL))))))); gegl_node_process (sink); test_end ("passthrough", gegl_buffer_get_pixel_count (buffer2) * 16); g_object_unref (gegl); g_object_unref (buffer2); return 0; }
gint main (gint argc, gchar **argv) { GeglBuffer *buffer, *buffer2; GeglNode *gegl, *source, *node1, *node2, *node3, *node4, *sink; gint i; gegl_init (&argc, &argv); buffer = test_buffer (2048, 1024, babl_format ("RGBA float")); #define ITERATIONS 16 test_start (); for (i=0;i< ITERATIONS;i++) { gegl = gegl_node_new (); source = gegl_node_new_child (gegl, "operation", "gegl:buffer-source", "buffer", buffer, NULL); node1 = gegl_node_new_child (gegl, "operation", "gegl:brightness-contrast", "contrast", 0.2, NULL); node2 = gegl_node_new_child (gegl, "operation", "gegl:brightness-contrast", "contrast", 0.2, NULL); node3 = gegl_node_new_child (gegl, "operation", "gegl:brightness-contrast", "contrast", 0.2, NULL); node4 = gegl_node_new_child (gegl, "operation", "gegl:brightness-contrast", "contrast", 0.2, NULL); sink = gegl_node_new_child (gegl, "operation", "gegl:buffer-sink", "buffer", &buffer2, NULL); gegl_node_link_many (source, node1, node2, node3, node4, sink, NULL); gegl_node_process (sink); g_object_unref (gegl); g_object_unref (buffer2); } test_end ("bcontrast_4x", gegl_buffer_get_pixel_count (buffer) * 16 * ITERATIONS); return 0; }
gint main (gint argc, gchar **argv) { GeglBuffer *buffer, *buffer2; GeglNode *gegl, *sink; gint i; g_thread_init (NULL); gegl_init (&argc, &argv); g_object_set (gegl_config (), "chunk-size", 128 * 128, NULL); buffer = test_buffer (1024, 1024, babl_format ("RGBA float")); #define ITERATIONS 6 test_start (); for (i=0;i< ITERATIONS;i++) { gegl = gegl_graph (sink = gegl_node ("gegl:buffer-sink", "buffer", &buffer2, NULL, gegl_node ("gegl:brightness-contrast", "contrast", 0.2, NULL, gegl_node ("gegl:buffer-source", "buffer", buffer, NULL)))); gegl_node_process (sink); g_object_unref (gegl); g_object_unref (buffer2); } test_end ("bcontrast-minichunk", gegl_buffer_get_pixel_count (buffer) * 16 * ITERATIONS); return 0; }
int main(int argc, const char * const *argv) { // if VALGRIND testing is enabled, we have to call ourselves with valgrind checking const char *valgrind = getenv("VALGRIND_TESTS"); if (!valgrind || !*valgrind || !strcmp(valgrind, "0")) { // fallthrough } else if (!strcmp(valgrind, "1")) { char cmd[strlen(argv[0]) + 256]; snprintf(cmd, sizeof(cmd), "VALGRIND_TESTS=\"\" valgrind --error-exitcode=301 --leak-check=yes --show-reachable=yes --track-origins=yes %s", argv[0]); return system(cmd) != 0; } else { char cmd[strlen(valgrind) + strlen(argv[0]) + 32]; snprintf(cmd, sizeof(cmd), "VALGRIND_TESTS="" %s %s", valgrind, argv[0]); return system(cmd) != 0; } init(argc, argv); // allows us to test with options (e.g. with --debug) srand((unsigned int) time(NULL)); // testing basic library functionality test_buffer(); test_buffer_printf(); test_utils(); test_strcasecmp_ascii(); test_vector(); test_stringmap(); if (failed) { info_printf("ERROR: %d out of %d basic tests failed\n", failed, ok + failed); info_printf("This may completely break Mget functionality !!!\n"); return 1; } test_iri_parse(); test_iri_relative_to_absolute(); test_iri_compare(); test_parser(); test_cookies(); test_hsts(); test_parse_challenge(); selftest_options() ? failed++ : ok++; deinit(); // free resources allocated by init() if (failed) { info_printf("Summary: %d out of %d tests failed\n", failed, ok + failed); return 1; } info_printf("Summary: All %d tests passed\n", ok + failed); return 0; }
void unit_tests() { test_buffer(); test_additions(); test_copy_constructor(); test_iteration(); test_rw_aggr_buf(); test_non_contiguous(); }
gint main (gint argc, gchar **argv) { GeglBuffer *buffer; gegl_init (&argc, &argv); buffer = test_buffer (1024, 1024, babl_format ("RGB float")); bench ("saturation (RGB)", buffer, &saturation); g_object_unref (buffer); buffer = test_buffer (1024, 1024, babl_format ("RGBA float")); bench ("saturation (RGBA)", buffer, &saturation); g_object_unref (buffer); buffer = test_buffer (1024, 1024, babl_format ("CIE Lab float")); bench ("saturation (CIE Lab)", buffer, &saturation); g_object_unref (buffer); buffer = test_buffer (1024, 1024, babl_format ("CIE Lab alpha float")); bench ("saturation (CIE Lab alpha)", buffer, &saturation); g_object_unref (buffer); buffer = test_buffer (1024, 1024, babl_format ("CIE LCH(ab) float")); bench ("saturation (CIE LCH(ab))", buffer, &saturation); g_object_unref (buffer); buffer = test_buffer (1024, 1024, babl_format ("CIE LCH(ab) alpha float")); bench ("saturation (CIE LCH(ab) alpha)", buffer, &saturation); g_object_unref (buffer); gegl_exit (); return 0; }
gint main (gint argc, gchar **argv) { GeglBuffer *buffer; gegl_init(&argc, &argv); buffer = test_buffer(1024, 1024, babl_format("RGB float")); bench("gaussian-blur (RGB)", buffer, &blur); g_object_unref (buffer); buffer = test_buffer(1024, 1024, babl_format("RaGaBaA float")); bench("gaussian-blur (RaGaBaA)", buffer, &blur); g_object_unref (buffer); buffer = test_buffer(1024, 1024, babl_format("RGBA float")); bench("gaussian-blur (RGBA)", buffer, &blur); g_object_unref (buffer); buffer = test_buffer(1024, 1024, babl_format("Y float")); bench("gaussian-blur (Y)", buffer, &blur); g_object_unref (buffer); buffer = test_buffer(1024, 1024, babl_format("YaA float")); bench("gaussian-blur (YaA)", buffer, &blur); g_object_unref (buffer); buffer = test_buffer(1024, 1024, babl_format("YA float")); bench("gaussian-blur (YA)", buffer, &blur); g_object_unref (buffer); gegl_exit (); return 0; }
gint main (gint argc, gchar **argv) { GeglBuffer *buffer; gegl_init (&argc, &argv); buffer = test_buffer (2048, 1024, babl_format ("RGBA float")); bench("bcontrast", buffer, &blur); return 0; }
int main() { #ifdef NDEBUG printf("Must compile without NDEBUG=1\n"); exit(-1); #endif test_buffer(); test_list(); test_linked_list(); printf(" Tests Finished. Zero Errors\n"); return 0; }
int main() { evented_buffer_t test_buffer(1000); std::array<std::thread, 4> threads; for (int i = 0; i < 3; ++i) { threads[i] = std::thread(reader_func, i, &test_buffer); } threads[3] = std::thread(writer_func, &test_buffer); for (int i = 0; i < 4; i++) { threads[i].join(); } return 0; }
int main(int argc, char *argv[]) { /*set_signal();*/ /*struct ac_event * event = event_listener_create(NULL, 4444, 32, 32);*/ /*if(!event) {*/ /*printf("create event failed\n");*/ /*}*/ /*while(!event_is_shutdown(event)) {*/ /*event_run(event, -1);*/ /*}*/ /*event_close(event);*/ test_buffer(); /*test_queue();*/ return 0; }
static void TestRStream(skiatest::Reporter* reporter) { static const char s[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; char copy[sizeof(s)]; SkRandom rand; for (int i = 0; i < 65; i++) { char* copyPtr = copy; SkMemoryStream mem(s, sizeof(s)); SkBufferStream buff(&mem, i); do { copyPtr += buff.read(copyPtr, rand.nextU() & 15); } while (copyPtr < copy + sizeof(s)); REPORTER_ASSERT(reporter, copyPtr == copy + sizeof(s)); REPORTER_ASSERT(reporter, memcmp(s, copy, sizeof(s)) == 0); } test_buffer(reporter); }
static void test_ber_tlv_builder_mms(void) { struct ber_tlv_iter top_iter, nested_iter; struct ber_tlv_builder top_builder, nested_builder; unsigned char buf[512], *pdu; unsigned int pdulen; ber_tlv_iter_init(&top_iter, valid_mms_params, sizeof(valid_mms_params)); g_assert(ber_tlv_builder_init(&top_builder, buf, sizeof(buf))); /* Copy the structure */ while (ber_tlv_iter_next(&top_iter) == TRUE) { g_assert(ber_tlv_builder_next(&top_builder, ber_tlv_iter_get_class(&top_iter), ber_tlv_iter_get_encoding(&top_iter), ber_tlv_iter_get_tag(&top_iter))); ber_tlv_iter_recurse(&top_iter, &nested_iter); g_assert(ber_tlv_builder_recurse(&top_builder, &nested_builder)); while (ber_tlv_iter_next(&nested_iter) == TRUE) { g_assert(ber_tlv_builder_next(&nested_builder, ber_tlv_iter_get_class(&nested_iter), ber_tlv_iter_get_encoding(&nested_iter), ber_tlv_iter_get_tag(&nested_iter))); g_assert(ber_tlv_builder_set_length(&nested_builder, ber_tlv_iter_get_length(&nested_iter))); memcpy(ber_tlv_builder_get_data(&nested_builder), ber_tlv_iter_get_data(&nested_iter), ber_tlv_iter_get_length(&nested_iter)); } ber_tlv_builder_optimize(&nested_builder, NULL, NULL); } ber_tlv_builder_optimize(&top_builder, &pdu, &pdulen); test_buffer(pdu, pdulen); }
gint main (gint argc, gchar **argv) { GeglBuffer *buffer, *buffer2; GeglNode *gegl, *sink; gegl_init (&argc, &argv); buffer = test_buffer (1024, 1024, babl_format ("RGBA float")); gegl = gegl_graph (sink = gegl_node ("gegl:buffer-sink", "buffer", &buffer2, NULL, gegl_node ("gegl:rotate", "degrees", 4.0, NULL, gegl_node ("gegl:buffer-source", "buffer", buffer, NULL)))); test_start (); gegl_node_process (sink); test_end ("rotate", gegl_buffer_get_pixel_count (buffer) * 16); g_object_unref (gegl); return 0; }
int main() #endif { do { int y, x; for(y = 0; y < 16; ++y){ printf("{"); for(x = 0; x < 16; ++x){ printf("%d, ", (2 * ( y / 8 ) + ( x / 8 ))); } printf("}\n"); } /* Print copyright information */ printf("Doubango Project\nCopyright (C) 2009 Mamadou Diop \n\n"); #if RUN_TEST_LISTS || RUN_TEST_ALL /* linked lists */ test_basic_list(); printf("\n\n"); test_complex_list(); printf("\n\n"); test_filtered_list(); printf("\n\n"); #endif #if RUN_TEST_HEAP || RUN_TEST_ALL /* heap */ test_heap(); printf("\n\n"); #endif #if RUN_TEST_STRINGS || RUN_TEST_ALL /* strings */ test_strings(); printf("\n\n"); #endif #if RUN_TEST_URL || RUN_TEST_ALL /* url */ test_url(); printf("\n\n"); #endif #if RUN_TEST_THREADS || RUN_TEST_ALL /* threads */ test_threads(); printf("\n\n"); #endif #if RUN_TEST_MUTEX || RUN_TEST_ALL /* mutex */ test_mutex(); printf("\n\n"); #endif #if RUN_TEST_CONDWAIT || RUN_TEST_ALL /* condwait */ test_condwait(); printf("\n\n"); #endif #if RUN_TEST_SEMAPHORE || RUN_TEST_ALL /* semaphore */ test_semaphore(); printf("\n\n"); #endif #if RUN_TEST_SAFEOBJECT || RUN_TEST_ALL /* safe object */ //test_safeobject(); printf("\n\n"); #endif #if RUN_TEST_OBJECT || RUN_TEST_ALL /* object */ //test_object(); printf("\n\n"); #endif #if RUN_TEST_PARAMS || RUN_TEST_ALL /* parameters */ test_params(); printf("\n\n"); #endif #if RUN_TEST_OPTIONS || RUN_TEST_ALL /* options */ test_options(); printf("\n\n"); #endif #if RUN_TEST_TIMER || RUN_TEST_ALL /* timer */ test_timer(); printf("\n\n"); #endif #if RUN_TEST_RUNNABLE || RUN_TEST_ALL /* test runnable. */ test_runnable(); printf("\n\n"); #endif #if RUN_TEST_BUFFER || RUN_TEST_ALL /* test buffer */ test_buffer(); #endif #if RUN_TEST_MD5 || RUN_TEST_ALL /* test md5 and hmac_md5 */ test_md5(); test_hmac_md5(); #endif #if RUN_TEST_SHA1 || RUN_TEST_ALL /* test sha1 and hmac_sha-1 */ test_sha1(); test_hmac_sha1(); #endif #if RUN_TEST_BASE64 || RUN_TEST_ALL /* test base64 encoding/decoding */ test_base64(); #endif #if RUN_TEST_UUID || RUN_TEST_ALL /* test fake UUID (version5) */ test_uuid(); #endif #if RUN_TEST_FSM || RUN_TEST_ALL /* test FSM */ test_fsm(); #endif } while(LOOP); getchar(); return 0; }
static HRESULT test_frequency(LPGUID lpGuid) { HRESULT rc; LPDIRECTSOUND dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL; DSBUFFERDESC bufdesc; DSCAPS dscaps; WAVEFORMATEX wfx, wfx1; DWORD f, r; int ref; int rates[] = { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 96000 }; /* Create the DirectSound object */ rc=DirectSoundCreate(lpGuid,&dso,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED, "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) return rc; /* Get the device capabilities */ ZeroMemory(&dscaps, sizeof(dscaps)); dscaps.dwSize=sizeof(dscaps); rc=IDirectSound_GetCaps(dso,&dscaps); ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; /* We must call SetCooperativeLevel before creating primary buffer */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DS_OK && primary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a primary buffer " "%s\n",DXGetErrorString8(rc)); if (rc==DS_OK && primary!=NULL) { rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL); ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %s\n", DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT1; for (f=0;f<sizeof(fmts)/sizeof(fmts[0]);f++) { for (r=0;r<sizeof(rates)/sizeof(rates[0]);r++) { init_format(&wfx,WAVE_FORMAT_PCM,11025,fmts[f].bits, fmts[f].channels); secondary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_CTRLFREQUENCY; bufdesc.dwBufferBytes=align((wfx.nAvgBytesPerSec*rates[r]/11025)* BUFFER_LEN/1000,wfx.nBlockAlign); bufdesc.lpwfxFormat=&wfx; if (winetest_interactive) { trace(" Testing a secondary buffer at %ldx%dx%d " "with a primary buffer at %ldx%dx%d\n", wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels, wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels); } rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DS_OK && secondary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a secondary " "buffer %s\n",DXGetErrorString8(rc)); if (rc==DS_OK && secondary!=NULL) { test_buffer(dso,&secondary,0,FALSE,0,FALSE,0, winetest_interactive,1.0,0,NULL,0,0,TRUE,rates[r]); ref=IDirectSoundBuffer_Release(secondary); ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " "should have 0\n",ref); } } } EXIT1: ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, " "should have 0\n",ref); } /* Set the CooperativeLevel back to normal */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); EXIT: ref=IDirectSound_Release(dso); ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref); if (ref!=0) return DSERR_GENERIC; return rc; }
/* * Test the primary buffer at different formats while keeping the * secondary buffer at a constant format. */ static HRESULT test_primary_secondary(LPGUID lpGuid) { HRESULT rc; LPDIRECTSOUND dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL; DSBUFFERDESC bufdesc; DSCAPS dscaps; WAVEFORMATEX wfx, wfx2; int f,ref; /* Create the DirectSound object */ rc=DirectSoundCreate(lpGuid,&dso,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED, "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) return rc; /* Get the device capabilities */ ZeroMemory(&dscaps, sizeof(dscaps)); dscaps.dwSize=sizeof(dscaps); rc=IDirectSound_GetCaps(dso,&dscaps); ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; /* We must call SetCooperativeLevel before creating primary buffer */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DS_OK && primary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a primary buffer " "%s\n",DXGetErrorString8(rc)); if (rc==DS_OK && primary!=NULL) { for (f=0;f<NB_FORMATS;f++) { /* We must call SetCooperativeLevel to be allowed to call * SetFormat */ /* DSOUND: Setting DirectSound cooperative level to * DSSCL_PRIORITY */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1], formats[f][2]); wfx2=wfx; rc=IDirectSoundBuffer_SetFormat(primary,&wfx); ok(rc==DS_OK,"IDirectSoundBuffer_SetFormat(%s) failed: %s\n", format_string(&wfx), DXGetErrorString8(rc)); /* There is no garantee that SetFormat will actually change the * format to what we asked for. It depends on what the soundcard * supports. So we must re-query the format. */ rc=IDirectSoundBuffer_GetFormat(primary,&wfx,sizeof(wfx),NULL); ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK && (wfx.wFormatTag!=wfx2.wFormatTag || wfx.nSamplesPerSec!=wfx2.nSamplesPerSec || wfx.wBitsPerSample!=wfx2.wBitsPerSample || wfx.nChannels!=wfx2.nChannels)) { trace("Requested primary format tag=0x%04x %ldx%dx%d " "avg.B/s=%ld align=%d\n", wfx2.wFormatTag,wfx2.nSamplesPerSec,wfx2.wBitsPerSample, wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign); trace("Got tag=0x%04x %ldx%dx%d avg.B/s=%ld align=%d\n", wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample, wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign); } /* Set the CooperativeLevel back to normal */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2); secondary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2; bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000, wfx.nBlockAlign); bufdesc.lpwfxFormat=&wfx2; if (winetest_interactive) { trace(" Testing a primary buffer at %ldx%dx%d with a " "secondary buffer at %ldx%dx%d\n", wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels, wfx2.nSamplesPerSec,wfx2.wBitsPerSample,wfx2.nChannels); } rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DS_OK && secondary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a secondary " "buffer %s\n",DXGetErrorString8(rc)); if (rc==DS_OK && secondary!=NULL) { test_buffer(dso,&secondary,0,FALSE,0,FALSE,0, winetest_interactive,1.0,0,NULL,0,0,FALSE,0); ref=IDirectSoundBuffer_Release(secondary); ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " "should have 0\n",ref); } } ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, " "should have 0\n",ref); } /* Set the CooperativeLevel back to normal */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); EXIT: ref=IDirectSound_Release(dso); ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref); if (ref!=0) return DSERR_GENERIC; return rc; }
static HRESULT test_primary(LPGUID lpGuid) { HRESULT rc; LPDIRECTSOUND dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL,second=NULL,third=NULL; DSBUFFERDESC bufdesc; DSCAPS dscaps; WAVEFORMATEX wfx; int ref; /* Create the DirectSound object */ rc=DirectSoundCreate(lpGuid,&dso,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED, "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) return rc; /* Get the device capabilities */ ZeroMemory(&dscaps, sizeof(dscaps)); dscaps.dwSize=sizeof(dscaps); rc=IDirectSound_GetCaps(dso,&dscaps); ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; /* DSOUND: Error: Invalid buffer description pointer */ rc=IDirectSound_CreateSoundBuffer(dso,0,0,NULL); ok(rc==DSERR_INVALIDPARAM, "IDirectSound_CreateSoundBuffer() should have failed: %s\n", DXGetErrorString8(rc)); /* DSOUND: Error: Invalid buffer description pointer */ rc=IDirectSound_CreateSoundBuffer(dso,0,&primary,NULL); ok(rc==DSERR_INVALIDPARAM && primary==0, "IDirectSound_CreateSoundBuffer() should have failed: rc=%s," "dsbo=%p\n",DXGetErrorString8(rc),primary); /* DSOUND: Error: Invalid buffer description pointer */ rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,0,NULL); ok(rc==DSERR_INVALIDPARAM && primary==0, "IDirectSound_CreateSoundBuffer() should have failed: rc=%s," "dsbo=0x%p\n",DXGetErrorString8(rc),primary); ZeroMemory(&bufdesc, sizeof(bufdesc)); /* DSOUND: Error: Invalid size */ /* DSOUND: Error: Invalid buffer description */ rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DSERR_INVALIDPARAM && primary==0, "IDirectSound_CreateSoundBuffer() should have failed: rc=%s," "primary=%p\n",DXGetErrorString8(rc),primary); /* We must call SetCooperativeLevel before calling CreateSoundBuffer */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); if (rc!=DS_OK) goto EXIT; /* Testing the primary buffer */ primary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME; bufdesc.lpwfxFormat = &wfx; init_format(&wfx,WAVE_FORMAT_PCM,11025,8,2); rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DSERR_INVALIDPARAM,"IDirectSound_CreateSoundBuffer() should have " "returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK && primary!=NULL) IDirectSoundBuffer_Release(primary); primary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok((rc==DS_OK && primary!=NULL) || (rc==DSERR_CONTROLUNAVAIL), "IDirectSound_CreateSoundBuffer() failed to create a primary buffer: " "%s\n",DXGetErrorString8(rc)); if (rc==DSERR_CONTROLUNAVAIL) trace(" No Primary\n"); else if (rc==DS_OK && primary!=NULL) { LONG vol; /* Try to create a second primary buffer */ /* DSOUND: Error: The primary buffer already exists. * Any changes made to the buffer description will be ignored. */ rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&second,NULL); ok(rc==DS_OK && second==primary, "IDirectSound_CreateSoundBuffer() should have returned original " "primary buffer: %s\n",DXGetErrorString8(rc)); ref=IDirectSoundBuffer_Release(second); ok(ref==1,"IDirectSoundBuffer_Release() primary has %d references, " "should have 1\n",ref); /* Try to duplicate a primary buffer */ /* DSOUND: Error: Can't duplicate primary buffers */ rc=IDirectSound_DuplicateSoundBuffer(dso,primary,&third); /* rc=0x88780032 */ ok(rc!=DS_OK,"IDirectSound_DuplicateSoundBuffer() primary buffer " "should have failed %s\n",DXGetErrorString8(rc)); rc=IDirectSoundBuffer_GetVolume(primary,&vol); ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %s\n", DXGetErrorString8(rc)); if (winetest_interactive) { trace("Playing a 5 seconds reference tone at the current " "volume.\n"); if (rc==DS_OK) trace("(the current volume is %ld according to DirectSound)\n", vol); trace("All subsequent tones should be identical to this one.\n"); trace("Listen for stutter, changes in pitch, volume, etc.\n"); } test_buffer(dso,&primary,1,FALSE,0,FALSE,0,winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),5.0,0,0,0,0,FALSE,0); ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, " "should have 0\n",ref); } /* Set the CooperativeLevel back to normal */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n", DXGetErrorString8(rc)); EXIT: ref=IDirectSound_Release(dso); ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref); if (ref!=0) return DSERR_GENERIC; return rc; }
/* * Tests: one buffer */ static void test1(void) { rba_buffer_t buffer; rational_t q0; q_init(&q0); init_rba_buffer(&buffer, &prod_table); printf("Empty buffer\n"); test_buffer(&buffer); printf("x_0 + x_1\n"); rba_buffer_add_var(&buffer, 0); rba_buffer_add_var(&buffer, 1); test_buffer(&buffer); printf("After reset\n"); reset_rba_buffer(&buffer); test_buffer(&buffer); printf("x_2 - x_0\n"); rba_buffer_add_var(&buffer, 2); rba_buffer_sub_var(&buffer, 0); test_buffer(&buffer); printf("x_2 - x_0 + x_1 + x_0\n"); reset_rba_buffer(&buffer); rba_buffer_add_var(&buffer, 2); rba_buffer_sub_var(&buffer, 0); rba_buffer_add_var(&buffer, 1); rba_buffer_add_var(&buffer, 0); test_buffer(&buffer); printf("Adding 3\n"); q_set32(&q0, 3); rba_buffer_add_const(&buffer, &q0); test_buffer(&buffer); printf("Negating\n"); rba_buffer_negate(&buffer); test_buffer(&buffer); printf("Negating again\n"); rba_buffer_negate(&buffer); test_buffer(&buffer); printf("Multiplying by 2 x_4\n"); q_set32(&q0, 2); rba_buffer_mul_varmono(&buffer, &q0, 4); test_buffer(&buffer); printf("Multiplying by x_1^2\n"); rba_buffer_mul_var(&buffer, 1); rba_buffer_mul_var(&buffer, 1); test_buffer(&buffer); printf("Multiplying by 0\n"); q_clear(&q0); rba_buffer_mul_const(&buffer, &q0); test_buffer(&buffer); printf("x_1 + 1 - x_2\n"); reset_rba_buffer(&buffer); rba_buffer_add_var(&buffer, 1); q_set32(&q0, 1); rba_buffer_add_const(&buffer, &q0); rba_buffer_sub_var(&buffer, 2); test_buffer(&buffer); printf("Squaring\n"); rba_buffer_square(&buffer); test_buffer(&buffer); printf("Squaring\n"); rba_buffer_square(&buffer); test_buffer(&buffer); printf("Squaring\n"); rba_buffer_square(&buffer); test_buffer(&buffer); q_clear(&q0); delete_rba_buffer(&buffer); }
void compila() { struct objeto *i; FILE *f; int n, l; unsigned long m; byte *q, *p; int start_lin, start_dbg; byte *varptr; /* variables indexadas */ FILE *fvar; ultima_linea = prog; acceso_remoto = 0; parametros = 0; linea = 1; linf = NULL; print_translate(27); /* inicio_textos debe ser como mínimo 256 */ if (imem < 256) imem = 256; itxt = inicio_textos = imem; psintactico(); /* Para obtener "longitud_textos" */ imem += longitud_textos; #ifdef _DEBUG printf("dbg: longitud_textos: %d\n", longitud_textos); #endif test_buffer(&mem, &imem_max, imem); if (n_errors > 0) return; num_obj_predefinidos = num_obj; ultima_linea = source; acceso_remoto = 0; parametros = 0; linea = 1; sintactico(); i = obj; while (i < iobj) { if (i->usado) { linea = i->linea; ierror = i->ierror; error(0, 34, i->name); /* nombre desconocido */ } i++; } if (n_errors > 0) return; /* Borra todo y comienza de nuevo :P */ print_translate(28); if (frm != NULL) { free(frm); frm = NULL; } if (loc != NULL) { free(loc); loc = NULL; } if (mem != NULL) { free(mem); mem = mem_ory = NULL; } if (vnom != NULL) { free(vnom); vnom = NULL; } prepara_compilacion(); source = prog; inicializa_index(); /* ahora toca construir el indice de variables */ dll_func2(); /* recarga sólo las dlls necesarias */ if (debug) { if ((linf = tmpfile()) == NULL) { print_translate(29); exit(1); } } /* inicio_textos debe ser como mínimo 256 */ if (imem < 256) imem = 256; itxt = inicio_textos = imem; imem += longitud_textos; test_buffer(&mem, &imem_max, imem); num_obj_predefinidos = num_obj; acceso_remoto = 0; parametros = 0; linea = 1; sintactico(); /* * Ahora que estamos en el final del bytecode, añadiremos la rutina que carga * las DLLs. Lo primero es guardar las cadenas con los nombres: */ for (n = 0; n < numdlls; n++) if (dlls[n].usado || dlls[n].prioridad >= P_SIEMPRE) { dlls[n].mem_nombre = imem; l = strlen(dlls[n].nombre); memcpy(&mem[imem], dlls[n].nombre, l + 1); imem += (l + 4) / 4; test_buffer(&mem, &imem_max, imem); } /* Si estamos compilando en modo debug, añadimos tambien la debug.dll */ if (debug) { dlls[numdlls].mem_nombre = imem; memcpy(&mem[imem], "debug", 6); imem += 2; test_buffer(&mem, &imem_max, imem); } /* * Ahora estamos en la posición donde comienza la rutina, por lo que tenemos * que guardar la posición actual en el offset que guardamos en salto_import */ mem[salto_import] = imem; /* Escribimos la rutina de carga de DLLs */ for (n = 0; n < numdlls; n++) if (dlls[n].usado || dlls[n].prioridad >= P_SIEMPRE) g2(limp, dlls[n].mem_nombre); if (debug) g2(limp, dlls[numdlls].mem_nombre); g2(ljmp, salto_import + 1); /* Ya está !! :) */ /* Preparamos la cabecera del bytecode */ mem[2] = imem; mem[3] = max_process; /* Antes long_header, ahora no se utiliza */ mem[4] = 0; /* Antes mem[1]-mem[3] (long datos globales), ahora no se utiliza */ mem[5] = iloc_len - iloc; mem[6] = iloc; mem[7] = 0; /* Antes imem+iloc (inicio textos), ahora no se utiliza */ mem[8] = imem + iloc; /* Número de elementos ocupados en mem[] */ /* * mem[0] se usa para almacenar flags para el ejecutable. En el caso de DIV 2, * éstas eran: * +1 = El programa es un setup de sonido (setup_program) * +128 = El programa invoca al trazador nada más ejecutarse (compilado con F12) * +512 = Se ignoran los errores de ejecución (ignore_errors) * +1024= Modo DEMO (mensaje en el centro de la pantalla parpadeando diciendo * "VERSIÓN DE DEMOSTRACIÓN") */ /* * nosotros usaremos las siguientes: * +16 = El exe lleva incluidas las DLL's * A ver como lo hacemos en Linux.. 1) con temporales o 2) hurgando en el codigo * de dlopen y demas y haciendonos una pekeña lib (esto es mas aconsejable) * +32 = El exe lleva incluido el PAK * +64 = Compilado en modo debug * +128 = Igual que en DIV2, el programa invoca al trazador nada más ejecutarse (se * ha usado la orden "trazar programa" en el IDE) * +512 = ignore_errors, igual que en DIV2 */ mem[0] = 0; if (debug) mem[0] += 64; if (ignore_errors) mem[0] += 512; /* * Generamos los listados (debe hacerse ahora porque en el listado de objetos guardamos * los valores de mem[1..8]) */ if (listados) { print_translate(30); if (listados & 1) listado_ensamblador(); if (listados & 2) listado_objetos(); } if (noexe) return; print_translate(31); /* descomprime la edivrun.lib y guarda una copia con el nombre temp.dj! */ _encriptar(0, edivrun_lib, la_clave); _comprimir(0, "temp.dj!"); /* si el archivo de salida ya existe, lo borra */ if ((f = fopen(outfilename, "rb")) != NULL) { fclose(f); remove(outfilename); } /* renombra temp.dj! al nombre del exe */ if (rename("temp.dj!", outfilename)) { print_translate(33); /* error escribiendo ejecutable */ remove("temp.dj!"); exit(1); } /* ordenamos varindex */ ordena_varindex(); /* escribimos en un temporal todo el indice de variables */ fvar = tmpfile(); for (n = 0; n < num_indexed_vars; n++) { fputc(varindex[n].hash, fvar); fwrite(varindex[n].nombre, 1, strlen(varindex[n].nombre) + 1, fvar); fwrite(&varindex[n].offset, 1, 4, fvar); fputc(varindex[n].tipo, fvar); } /* liberamos varindex */ for (n = 0; n < num_indexed_vars; n++) free(varindex[n].nombre); free(varindex); /* lo pasamos todo del temporal a la memoria */ l = ftell(fvar); fseek(fvar, 0, SEEK_SET); varptr = e_malloc(l); fread(varptr, 1, l, fvar); fclose(fvar); #ifdef _DEBUG if (fvar = fopen("varindex.out", "wb")) { fwrite(varptr, 1, l, fvar); fclose(fvar); } #endif if ((f = fopen(outfilename, "ab")) != NULL) { fwrite(nombre_program, strlen((const char *)nombre_program) + 1, 1, f); p = e_malloc((imem + iloc) * 4); m = (imem + iloc) * 4 + 1024; q = e_malloc(m); if (p != NULL && q != NULL) { fwrite(mem, 4, 9, f); /* mem[0..8] */ memcpy(p, &mem[9], (imem - 9) * 4); memcpy(p + (imem - 9) * 4, loc, iloc * 4); n = (imem - 9 + iloc) * 4; if (!compress(q, &m, p, n)) { fwrite(&n, 1, 4, f); /* mem[0]..mem[8],longitud_datos_descomp,longitud_datos_comp,datos comp... */ fwrite(&m, 1, sizeof(unsigned long), f); fwrite(q, 1, m, f); free(q); free(p); m = l * 2; q = e_malloc(m); if (!compress(q, &m, varptr, l)) { /* nºvariables,longitud_datos_descomp,longitud_datos_comp,datos_comp... */ fwrite(&num_indexed_vars, 1, 4, f); fwrite(&l, 1, 4, f); fwrite(&m, 1, sizeof(unsigned long), f); fwrite(q, 1, m, f); free(q); free(varptr); if (debug) { /* formato de ejecutable de debug */ print_translate(32); start_lin = ftell(f); escribe_lin(f); start_dbg = ftell(f); escribe_dbg(f); fwrite(&start_lin, 1, 4, f); fwrite(&start_dbg, 1, 4, f); } fwrite(&stub_size, 1, 4, f); /* Ultimos 4 bytes siempre son el tamaño del stub */ fclose(f); } else { free(q); free(varptr); fclose(f); errormem(); } } else { free(q); free(p); free(varptr); fclose(f); errormem(); } } else { if (p != NULL) free(p); if (q != NULL) free(q); free(varptr); fclose(f); errormem(); } } else { free(varptr); print_translate(33); exit(1); } #ifndef _WIN32 chmod(outfilename, 493); /* -rwxr-xr-x */ #endif print_translate(34); }
BOOL check_x264_mp4_output(const char *exe_path, const char *temp_filename) { BOOL ret = FALSE; std::string exe_message; PROCESS_INFORMATION pi = { 0 }; const int TEST_WIDTH = 160; const int TEST_HEIGHT = 120; std::vector<char> test_buffer(TEST_WIDTH * TEST_HEIGHT * 3 / 2, 0); PIPE_SET pipes = { 0 }; InitPipes(&pipes); pipes.stdIn.mode = AUO_PIPE_ENABLE; pipes.stdOut.mode = AUO_PIPE_DISABLE; pipes.stdErr.mode = AUO_PIPE_ENABLE; pipes.stdIn.bufferSize = test_buffer.size(); char test_path[1024] = { 0 }; for (int i = 0; !i || PathFileExists(test_path); i++) { char test_filename[32] = { 0 }; sprintf_s(test_filename, _countof(test_filename), "_test_%d.mp4", i); PathCombineLong(test_path, _countof(test_path), temp_filename, test_filename); } char exe_dir[1024] = { 0 }; strcpy_s(exe_dir, _countof(exe_dir), exe_path); PathRemoveFileSpecFixed(exe_dir); char fullargs[8192] = { 0 }; sprintf_s(fullargs, _countof(fullargs), "\"%s\" --fps 1 --frames 1 --input-depth 8 --input-res %dx%d -o \"%s\" --input-csp nv12 -", exe_path, TEST_WIDTH, TEST_HEIGHT, test_path); if ((ret = RunProcess(fullargs, exe_dir, &pi, &pipes, NORMAL_PRIORITY_CLASS, TRUE, FALSE)) == RP_SUCCESS) { while (WAIT_TIMEOUT == WaitForInputIdle(pi.hProcess, LOG_UPDATE_INTERVAL)) log_process_events(); _fwrite_nolock(&test_buffer[0], 1, test_buffer.size(), pipes.f_stdin); auto read_stderr = [](PIPE_SET *pipes) { DWORD pipe_read = 0; if (!PeekNamedPipe(pipes->stdErr.h_read, NULL, 0, NULL, &pipe_read, NULL)) return -1; if (pipe_read) { ReadFile(pipes->stdErr.h_read, pipes->read_buf + pipes->buf_len, sizeof(pipes->read_buf) - pipes->buf_len - 1, &pipe_read, NULL); pipes->buf_len += pipe_read; pipes->read_buf[pipes->buf_len] = '\0'; } return (int)pipe_read; }; while (WAIT_TIMEOUT == WaitForSingleObject(pi.hProcess, 10)) { if (read_stderr(&pipes)) { exe_message += pipes.read_buf; pipes.buf_len = 0; } else { log_process_events(); } } CloseStdIn(&pipes); while (read_stderr(&pipes) > 0) { exe_message += pipes.read_buf; pipes.buf_len = 0; } log_process_events(); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); if (std::string::npos == exe_message.find("not compiled with MP4 output")) ret = TRUE; } if (pipes.stdIn.mode) CloseHandle(pipes.stdIn.h_read); if (pipes.stdOut.mode) CloseHandle(pipes.stdOut.h_read); if (pipes.stdErr.mode) CloseHandle(pipes.stdErr.h_read); if (PathFileExists(test_path)) remove(test_path); return ret; }
static void test_ber_tlv_iter(void) { test_buffer(valid_mms_params, sizeof(valid_mms_params)); }
static HRESULT test_secondary(LPGUID lpGuid) { HRESULT rc; LPDIRECTSOUND dso=NULL; LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL; DSBUFFERDESC bufdesc; DSCAPS dscaps; WAVEFORMATEX wfx, wfx1; DWORD f; int ref; /* Create the DirectSound object */ rc=pDirectSoundCreate(lpGuid,&dso,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED, "DirectSoundCreate() failed: %08x\n",rc); if (rc!=DS_OK) return rc; /* Get the device capabilities */ ZeroMemory(&dscaps, sizeof(dscaps)); dscaps.dwSize=sizeof(dscaps); rc=IDirectSound_GetCaps(dso,&dscaps); ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %08x\n",rc); if (rc!=DS_OK) goto EXIT; /* We must call SetCooperativeLevel before creating primary buffer */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc); if (rc!=DS_OK) goto EXIT; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); ok(rc==DS_OK && primary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a primary buffer %08x\n",rc); if (rc==DS_OK && primary!=NULL) { rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL); ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %08x\n", rc); if (rc!=DS_OK) goto EXIT1; for (f=0;f<NB_FORMATS;f++) { WAVEFORMATEXTENSIBLE wfxe; init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1], formats[f][2]); secondary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2; bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000, wfx.nBlockAlign); rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DSERR_INVALIDPARAM,"IDirectSound_CreateSoundBuffer() " "should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc); if (rc==DS_OK && secondary!=NULL) IDirectSoundBuffer_Release(secondary); secondary=NULL; ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2; bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000, wfx.nBlockAlign); bufdesc.lpwfxFormat=&wfx; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); if (gotdx8 || wfx.wBitsPerSample <= 16) { if (wfx.wBitsPerSample > 16) ok(((rc == DSERR_CONTROLUNAVAIL || rc == DSERR_INVALIDCALL || rc == DSERR_INVALIDPARAM /* 2003 */) && !secondary) || rc == DS_OK, /* driver dependent? */ "IDirectSound_CreateSoundBuffer() " "should have returned (DSERR_CONTROLUNAVAIL or DSERR_INVALIDCALL) " "and NULL, returned: %08x %p\n", rc, secondary); else ok(rc==DS_OK && secondary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a secondary buffer %08x\n",rc); } else ok(rc==E_INVALIDARG, "Creating %d bpp buffer on dx < 8 returned: %p %08x\n", wfx.wBitsPerSample, secondary, rc); if (!gotdx8) { skip("Not doing the WAVE_FORMAT_EXTENSIBLE tests\n"); /* Apparently they succeed with bogus values, * which means that older dsound doesn't look at them */ goto no_wfe; } if (secondary) IDirectSoundBuffer_Release(secondary); secondary = NULL; bufdesc.lpwfxFormat=(WAVEFORMATEX*)&wfxe; wfxe.Format = wfx; wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; wfxe.Format.cbSize = 1; wfxe.Samples.wValidBitsPerSample = wfx.wBitsPerSample; wfxe.dwChannelMask = (wfx.nChannels == 1 ? KSAUDIO_SPEAKER_MONO : KSAUDIO_SPEAKER_STEREO); rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok((rc==DSERR_INVALIDPARAM || rc==DSERR_INVALIDCALL /* 2003 */) && !secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx) + 1; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(((rc==DSERR_CONTROLUNAVAIL || rc==DSERR_INVALIDCALL || rc==DSERR_INVALIDPARAM) && !secondary) || rc==DS_OK, /* 2003 / 2008 */ "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx); wfxe.SubFormat = GUID_NULL; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok((rc==DSERR_INVALIDPARAM || rc==DSERR_INVALIDCALL) && !secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; ++wfxe.Samples.wValidBitsPerSample; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DSERR_INVALIDPARAM && !secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } --wfxe.Samples.wValidBitsPerSample; wfxe.Samples.wValidBitsPerSample = 0; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DS_OK && secondary, "IDirectSound_CreateSoundBuffer() returned: %08x %p\n", rc, secondary); if (secondary) { IDirectSoundBuffer_Release(secondary); secondary=NULL; } wfxe.Samples.wValidBitsPerSample = wfxe.Format.wBitsPerSample; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DS_OK && secondary!=NULL, "IDirectSound_CreateSoundBuffer() failed to create a secondary buffer %08x\n",rc); no_wfe: if (rc==DS_OK && secondary!=NULL) { if (winetest_interactive) { trace(" Testing a secondary buffer at %dx%dx%d " "with a primary buffer at %dx%dx%d\n", wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels, wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels); } test_buffer(dso,&secondary,0,FALSE,0,FALSE,0, winetest_interactive,1.0,0,NULL,0,0,FALSE,0); ref=IDirectSoundBuffer_Release(secondary); ok(ref==0,"IDirectSoundBuffer_Release() has %d references, " "should have 0\n",ref); } } EXIT1: ref=IDirectSoundBuffer_Release(primary); ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, " "should have 0\n",ref); } /* Set the CooperativeLevel back to normal */ /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL); ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc); EXIT: ref=IDirectSound_Release(dso); ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref); if (ref!=0) return DSERR_GENERIC; return rc; }
/* * Tests: one buffer * - n = bitsize */ static void test1(uint32_t n) { bvarith_buffer_t buffer; uint32_t q0[4]; assert(0 < n && n <= 128); init_bvarith_buffer(&buffer, &prod_table, &store); bvarith_buffer_prepare(&buffer, n); printf("Empty buffer\n"); test_buffer(&buffer); printf("x_0 + x_1\n"); bvarith_buffer_add_var(&buffer, 0); bvarith_buffer_add_var(&buffer, 1); bvarith_buffer_normalize(&buffer); test_buffer(&buffer); printf("After reset\n"); bvarith_buffer_prepare(&buffer, n); test_buffer(&buffer); printf("x_2 - x_0\n"); bvarith_buffer_add_var(&buffer, 2); bvarith_buffer_sub_var(&buffer, 0); bvarith_buffer_normalize(&buffer); test_buffer(&buffer); printf("x_2 - x_0 + x_1 + x_0\n"); bvarith_buffer_prepare(&buffer, n); bvarith_buffer_add_var(&buffer, 2); bvarith_buffer_sub_var(&buffer, 0); bvarith_buffer_add_var(&buffer, 1); bvarith_buffer_add_var(&buffer, 0); bvarith_buffer_normalize(&buffer); test_buffer(&buffer); printf("Adding 3\n"); bvconst_set32(q0, 4, 3); bvarith_buffer_add_const(&buffer, q0); bvarith_buffer_normalize(&buffer); test_buffer(&buffer); printf("Negating\n"); bvarith_buffer_negate(&buffer); bvarith_buffer_normalize(&buffer); test_buffer(&buffer); printf("Negating again\n"); bvarith_buffer_negate(&buffer); bvarith_buffer_normalize(&buffer); test_buffer(&buffer); printf("Multiplying by 2 x_4\n"); bvconst_set32(q0, 4, 2); bvarith_buffer_mul_varmono(&buffer, q0, 4); bvarith_buffer_normalize(&buffer); test_buffer(&buffer); printf("Multiplying by x_1^2\n"); bvarith_buffer_mul_var(&buffer, 1); bvarith_buffer_mul_var(&buffer, 1); bvarith_buffer_normalize(&buffer); test_buffer(&buffer); printf("Multiplying by 0\n"); bvconst_clear(q0, 4); bvarith_buffer_mul_const(&buffer, q0); bvarith_buffer_normalize(&buffer); test_buffer(&buffer); printf("x_1 + 1 - x_2\n"); bvarith_buffer_prepare(&buffer, n); bvarith_buffer_add_var(&buffer, 1); bvconst_set32(q0, 4, 1); bvarith_buffer_add_const(&buffer, q0); bvarith_buffer_sub_var(&buffer, 2); bvarith_buffer_normalize(&buffer); test_buffer(&buffer); printf("Squaring\n"); bvarith_buffer_square(&buffer); bvarith_buffer_normalize(&buffer); test_buffer(&buffer); printf("Squaring\n"); bvarith_buffer_square(&buffer); bvarith_buffer_normalize(&buffer); test_buffer(&buffer); printf("Squaring\n"); bvarith_buffer_square(&buffer); bvarith_buffer_normalize(&buffer); test_buffer(&buffer); delete_bvarith_buffer(&buffer); }
/* * void sentencia(void) * Analiza un bloque de sentencias */ void sentencia(void) { int im1, im2, im3, im4; int dir, from, to, step; while (pieza >= p_return) { test_buffer(&mem, &imem_max, imem); switch (pieza) { case p_return: inicio_sentencia(); lexico(); if (pieza == p_abrir) { lexico(); if (pieza != p_cerrar) { expresion(); if (pieza != p_cerrar) error(3, 18); /* esperando ')' */ g1(lrtf); } else { g1(lret); } lexico(); } else { g1(lret); } if (!free_sintax) if (pieza != p_ptocoma) error(3, 9); /* esperando ';' */ while (pieza == p_ptocoma || pieza == p_coma) lexico(); final_sentencia(); grabar_sentencia(); break; case p_if: telseif[itelseif++] = 0; inicio_sentencia(); lexico(); if (!free_sintax) if (pieza != p_abrir) error(3, 22); /* esperando '(' */ if (pieza == p_abrir) lexico(); condicion(); if (!free_sintax) if (pieza != p_cerrar) error(3, 18); /* esperando ')' */ if (pieza == p_cerrar) lexico(); g2(ljpf, 0); im1 = imem - 1; final_sentencia(); grabar_sentencia(); if1: sentencia(); if (pieza == p_else) { inicio_sentencia(); lexico(); g2(ljmp, 0); mem[im1] = imem; im1 = imem - 1; final_sentencia(); grabar_sentencia(); sentencia(); } else if (pieza == p_elseif) { if (itelseif == 0) error(0, 73); /* elseif fuera de bloque if */ inicio_sentencia(); g2(ljmp, 0); telseif[itelseif++] = imem - 1; mem[im1] = imem; lexico(); if (!free_sintax) if (pieza != p_abrir) error(3, 22); /* esperando '(' */ if (pieza == p_abrir) lexico(); condicion(); if (!free_sintax) if (pieza != p_cerrar) error(3, 18); /* esperando ')' */ if (pieza == p_cerrar) lexico(); g2(ljpf, 0); im1 = imem - 1; final_sentencia(); grabar_sentencia(); goto if1; } mem[im1] = imem; if (pieza != p_end) error(0, 57); lexico(); /* esperando END */ while (telseif[--itelseif] != 0) mem[telseif[itelseif]] = imem; break; case p_loop: tbreak[itbreak++] = 0; tcont[itcont++] = 0; lexico(); im1 = imem; sentencia(); if (pieza != p_end) error(0, 57); /* esperando END */ inicio_sentencia(); lexico(); g2(ljmp, im1); while (tbreak[--itbreak] != 0) mem[tbreak[itbreak]] = imem; while (tcont[--itcont] != 0) mem[tcont[itcont]] = im1; final_sentencia(); grabar_sentencia(); break; case p_while: inicio_sentencia(); tbreak[itbreak++] = 0; tcont[itcont++] = 0; im1 = imem; lexico(); if (!free_sintax) if (pieza != p_abrir) error(3, 22); /* esperando '(' */ if (pieza == p_abrir) lexico(); condicion(); if (!free_sintax) if (pieza != p_cerrar) error(3, 18); /* esperando ')' */ if (pieza == p_cerrar) lexico(); g2(ljpf, 0); im2 = imem - 1; final_sentencia(); grabar_sentencia(); sentencia(); if (pieza != p_end) error(0, 57); inicio_sentencia(); /* esperando END */ lexico(); g2(ljmp, im1); mem[im2] = imem; while (tbreak[--itbreak] != 0) mem[tbreak[itbreak]] = imem; while (tcont[--itcont] != 0) mem[tcont[itcont]] = im1; final_sentencia(); grabar_sentencia(); break; case p_repeat: tbreak[itbreak++] = 0; tcont[itcont++] = 0; lexico(); im1 = imem; sentencia(); if (pieza != p_until) error(0, 58); /* esperando UNTIL */ inicio_sentencia(); lexico(); if (!free_sintax) if (pieza != p_abrir) error(3, 22); /* esperando '(' */ if (pieza == p_abrir) lexico(); condicion(); if (!free_sintax) if (pieza != p_cerrar) error(3, 18); /* esperando ')' */ if (pieza == p_cerrar) lexico(); g2(ljpf, im1); while (tbreak[--itbreak] != 0) mem[tbreak[itbreak]] = imem; while (tcont[--itcont] != 0) mem[tcont[itcont]] = im1; final_sentencia(); grabar_sentencia(); break; case p_from: inicio_sentencia(); tbreak[itbreak++] = 0; tcont[itcont++] = 0; lexico(); if (pieza != p_id) error(0, 59); /* esperando una variable */ if (o->tipo == tvglo) { dir = o->vglo.offset; g2(lcar, dir); } else if (o->tipo == tvloc && (!o->bloque || o->bloque == bloque_actual)) { dir = -o->vloc.offset; g2(lcar, -dir); g1(laid); } else error(0, 59); /* esperando una variable */ lexico(); if (pieza != p_asig) error(3, 7); lexico(); /* esperando '=' */ from = constante(); if (pieza != p_to) error(1, 60); lexico(); /* esperando TO */ to = constante(); if (from == to) error(4, 61); /* sentencia FROM incorrecta */ if (pieza == p_step) { lexico(); step = constante(); if (from < to && step <= 0) error(4, 62); /* el valor step no es válido */ if (from > to && step >= 0) error(4, 62); } else { if (from < to) step = 1; else step = -1; } g2(lcar, from); /* Asignación del from */ g1(lasi); g1(lasp); im1 = imem; /* Inicio del bucle */ if (dir >= 0) { /* Comparación de la condición de permanencia */ g2(lcar, dir); } else { g2(lcar, -dir); g1(laid); } g1(lptr); g2(lcar, to); if (step > 0) g1(lmei); else g1(lmai); g2(ljpf, 0); im2 = imem - 1; final_sentencia(); grabar_sentencia(); if (!free_sintax) if (pieza != p_ptocoma) error(3, 9); /* esperando ';' */ while (pieza == p_ptocoma || pieza == p_coma) lexico(); sentencia(); if (pieza != p_end) error(0, 57); inicio_sentencia(); /* esperando END */ lexico(); im3 = imem; /* Posición del continue */ if (dir >= 0) { /* Incremento y vuelta al inicio del bucle */ g2(lcar, dir); } else { g2(lcar, -dir); g1(laid); } g2(lcar, step); g1(lada); g1(lasp); g2(ljmp, im1); mem[im2] = imem; while (tbreak[--itbreak] != 0) mem[tbreak[itbreak]] = imem; while (tcont[--itcont] != 0) mem[tcont[itcont]] = im3; final_sentencia(); grabar_sentencia(); break; case p_for: inicio_sentencia(); tbreak[itbreak++] = 0; tcont[itcont++] = 0; lexico(); if (pieza != p_abrir) error(3, 22); lexico(); /* esperando '(' */ if (pieza != p_ptocoma) { expresion(); g1(lasp); while (pieza == p_coma) { lexico(); expresion(); g1(lasp); } } im1 = imem; if (pieza != p_ptocoma) error(3, 9); lexico(); /* esperando ';' */ if (pieza == p_ptocoma) { g2(lcar, 1); } else expresion(); g2(ljpf, 0); im2 = imem - 1; while (pieza == p_coma) { lexico(); expresion(); g2(ljpf, im2); im2 = imem - 1; } g2(ljmp, 0); im3 = imem - 1; if (pieza != p_ptocoma) error(3, 9); lexico(); /* esperando ';' */ if (pieza != p_cerrar) { expresion(); g1(lasp); while (pieza == p_coma) { lexico(); expresion(); g1(lasp); } } g2(ljmp, im1); if (pieza != p_cerrar) error(3, 18); lexico(); /* esperando ')' */ final_sentencia(); grabar_sentencia(); mem[im3++] = imem; sentencia(); if (pieza != p_end) error(0, 57); /* esperando END */ inicio_sentencia(); lexico(); g2(ljmp, im3); do { im1 = mem[im2]; mem[im2] = imem; im2 = im1; } while (im2); while (tbreak[--itbreak] != 0) mem[tbreak[itbreak]] = imem; while (tcont[--itcont] != 0) mem[tcont[itcont]] = im3; final_sentencia(); grabar_sentencia(); break; case p_switch: inicio_sentencia(); lexico(); if (!free_sintax) if (pieza != p_abrir) error(3, 22); /* esperando '(' */ if (pieza == p_abrir) lexico(); condicion(); if (!free_sintax) if (pieza != p_cerrar) error(3, 18); /* esperando ')' */ if (pieza == p_cerrar) lexico(); while (pieza == p_ptocoma) { lexico(); } final_sentencia(); grabar_sentencia(); im1 = 0; im2 = 0; while (pieza != p_end) { inicio_sentencia(); if (pieza == p_case) { im3 = 0; do { lexico(); if (im1) mem[im1] = imem; expresion(); if (pieza != p_rango) { g2(lcse, 0); im1 = imem - 1; } else { lexico(); expresion(); g2(lcsr, 0); im1 = imem - 1; } if (pieza == p_coma) { g2(ljmp, im3); im3 = imem - 1; } } while (pieza == p_coma); while (im3) { im4 = mem[im3]; mem[im3] = imem; im3 = im4; } } else if (pieza == p_default) { lexico(); if (im1) mem[im1] = imem; im1 = 0; } else error(0, 63); /* esperando case, default o end */ if (!free_sintax) if (pieza != p_ptocoma) error(3, 64); /* esperando ':' */ while (pieza == p_ptocoma || pieza == p_coma) lexico(); g1(lasp); final_sentencia(); grabar_sentencia(); sentencia(); if (pieza != p_end) error(0, 57); /* esperando END */ inicio_sentencia(); g2(ljmp, im2); im2 = imem - 1; pasa_ptocoma(); final_sentencia(); grabar_sentencia(); } inicio_sentencia(); if (im1) mem[im1] = imem; g1(lasp); while (im2) { im1 = mem[im2]; mem[im2] = imem; im2 = im1; } lexico(); final_sentencia(); grabar_sentencia(); break; case p_frame: inicio_sentencia(); lexico(); if (pieza == p_abrir) { lexico(); if (pieza != p_cerrar) { expresion(); if (pieza != p_cerrar) error(3, 18); /* esperando ')' */ g1(lfrf); } else { g1(lfrm); } lexico(); } else { g1(lfrm); } if (!free_sintax) if (pieza != p_ptocoma) error(3, 9); /* esperando ';' */ while (pieza == p_ptocoma || pieza == p_coma) lexico(); final_sentencia(); grabar_sentencia(); break; case p_debug: inicio_sentencia(); g1(ldbg); lexico(); if (!free_sintax) if (pieza != p_ptocoma) error(3, 9); /* esperando ';' */ while (pieza == p_ptocoma || pieza == p_coma) lexico(); final_sentencia(); grabar_sentencia(); break; case p_break: inicio_sentencia(); if (itbreak == 0) error(0, 65); lexico(); /* break fuera de un bucle */ if (!free_sintax) if (pieza != p_ptocoma) error(3, 9); /* esperando ';' */ while (pieza == p_ptocoma || pieza == p_coma) lexico(); g2(ljmp, 0); tbreak[itbreak++] = imem - 1; final_sentencia(); grabar_sentencia(); break; case p_continue: inicio_sentencia(); if (itcont == 0) error(0, 66); lexico(); /* continue fuera de un bucle */ if (!free_sintax) if (pieza != p_ptocoma) error(3, 9); /* esperando ';' */ while (pieza == p_ptocoma || pieza == p_coma) lexico(); g2(ljmp, 0); tcont[itcont++] = imem - 1; final_sentencia(); grabar_sentencia(); break; case p_clone: inicio_sentencia(); lexico(); g2(lclo, 0); im1 = imem - 1; final_sentencia(); grabar_sentencia(); sentencia(); if (pieza != p_end) error(0, 57); lexico(); /* esperando END */ mem[im1] = imem; break; case p_ptocoma: lexico(); break; default: inicio_sentencia(); error_25 = 67; expresion(); do { _exp--; } while ((*_exp).tipo == eoper && (*_exp).token == p_string); error_25 = 25; switch ((*_exp).tipo) { case ecall: break; case efext: break; case eoper: switch ((*_exp).token) { case p_asig: case p_inc: case p_suma: case p_dec: case p_resta: case p_add_asig: case p_sub_asig: case p_mul_asig: case p_div_asig: case p_mod_asig: case p_and_asig: case p_or_asig: case p_xor_asig: case p_shr_asig: case p_shl_asig: case p_asigword: case p_incword: case p_sumaword: case p_decword: case p_restaword: case p_add_asigword: case p_sub_asigword: case p_mul_asigword: case p_div_asigword: case p_mod_asigword: case p_and_asigword: case p_or_asigword: case p_xor_asigword: case p_shr_asigword: case p_shl_asigword: case p_asigchar: case p_incchar: case p_sumachar: case p_decchar: case p_restachar: case p_add_asigchar: case p_sub_asigchar: case p_mul_asigchar: case p_div_asigchar: case p_mod_asigchar: case p_and_asigchar: case p_or_asigchar: case p_xor_asigchar: case p_shr_asigchar: case p_shl_asigchar: case p_strcpy: case p_strcat: case p_strsub: break; default: error(4, 68); break; /* expresion sin sentido */ } break; default: error(4, 68); /* expresion sin sentido */ } if (!free_sintax) if (pieza != p_ptocoma) error(3, 9); /* esperando ';' */ while (pieza == p_ptocoma || pieza == p_coma) lexico(); g1(lasp); final_sentencia(); grabar_sentencia(); break; } } }
int main() { test_buffer(); return 0; }
int main(void) { thvar_t x, y, z; init_bvconstants(); init_bv_vartable(&vtbl); init_bvexp_table(&table, &vtbl); bvexp_init_buffer64(&table, &b1); bvexp_init_buffer64(&table, &b2); bvexp_init_buffer(&table, &c1); bvexp_init_buffer(&table, &c2); printf("=== Initial table ===\n"); print_bvexp_table(stdout, &table); printf("\n"); x = make_bvvar(&vtbl, 10); y = make_bvvar(&vtbl, 10); z = make_bvvar(&vtbl, 10); // 2 + x + y bvarith64_buffer_prepare(&b1, 10); bvarith64_buffer_add_const(&b1, 2); bvarith64_buffer_add_var(&b1, x); bvarith64_buffer_add_var(&b1, y); bvarith64_buffer_normalize(&b1); test_buffer64(&table, &b1); bvarith64_buffer_prepare(&b1, 10); bvarith64_buffer_add_const(&b1, 2); bvarith64_buffer_add_var(&b1, x); bvarith64_buffer_add_var(&b1, y); bvarith64_buffer_normalize(&b1); test_buffer64(&table, &b1); // (x + z) * (y - z) bvarith64_buffer_prepare(&b1, 10); bvarith64_buffer_add_var(&b1, x); bvarith64_buffer_add_var(&b1, z); bvarith64_buffer_prepare(&b2, 10); bvarith64_buffer_add_var(&b2, y); bvarith64_buffer_sub_var(&b2, z); bvarith64_buffer_mul_buffer(&b1, &b2); bvarith64_buffer_normalize(&b1); test_buffer64(&table, &b1); bvarith64_buffer_prepare(&b1, 10); bvarith64_buffer_add_var(&b1, x); bvarith64_buffer_add_var(&b1, z); bvarith64_buffer_prepare(&b2, 10); bvarith64_buffer_add_var(&b2, y); bvarith64_buffer_sub_var(&b2, z); bvarith64_buffer_mul_buffer(&b1, &b2); bvarith64_buffer_normalize(&b1); test_buffer64(&table, &b1); // x * y * z^2 bvarith64_buffer_prepare(&b1, 10); bvarith64_buffer_add_var(&b1, z); bvarith64_buffer_square(&b1); bvarith64_buffer_mul_var(&b1, y); bvarith64_buffer_mul_var(&b1, x); bvarith64_buffer_normalize(&b1); test_buffer64(&table, &b1); bvarith64_buffer_prepare(&b1, 10); bvarith64_buffer_add_var(&b1, z); bvarith64_buffer_square(&b1); bvarith64_buffer_mul_var(&b1, y); bvarith64_buffer_mul_var(&b1, x); bvarith64_buffer_normalize(&b1); test_buffer64(&table, &b1); // Large coefficients x = make_bvvar(&vtbl, 100); y = make_bvvar(&vtbl, 100); z = make_bvvar(&vtbl, 100); // 1 + x + y bvarith_buffer_prepare(&c1, 100); bvarith_buffer_set_one(&c1); bvarith_buffer_add_var(&c1, x); bvarith_buffer_add_var(&c1, y); bvarith_buffer_normalize(&c1); test_buffer(&table, &c1); bvarith_buffer_prepare(&c1, 100); bvarith_buffer_set_one(&c1); bvarith_buffer_add_var(&c1, x); bvarith_buffer_add_var(&c1, y); bvarith_buffer_normalize(&c1); test_buffer(&table, &c1); // (x + z) * (y - z) bvarith_buffer_prepare(&c1, 100); bvarith_buffer_add_var(&c1, x); bvarith_buffer_add_var(&c1, z); bvarith_buffer_prepare(&c2, 100); bvarith_buffer_add_var(&c2, y); bvarith_buffer_sub_var(&c2, z); bvarith_buffer_mul_buffer(&c1, &c2); bvarith_buffer_normalize(&c1); test_buffer(&table, &c1); bvarith_buffer_prepare(&c1, 100); bvarith_buffer_add_var(&c1, x); bvarith_buffer_add_var(&c1, z); bvarith_buffer_prepare(&c2, 100); bvarith_buffer_add_var(&c2, y); bvarith_buffer_sub_var(&c2, z); bvarith_buffer_mul_buffer(&c1, &c2); bvarith_buffer_normalize(&c1); test_buffer(&table, &c1); // x * y * z^2 bvarith_buffer_prepare(&c1, 100); bvarith_buffer_add_var(&c1, z); bvarith_buffer_square(&c1); bvarith_buffer_mul_var(&c1, y); bvarith_buffer_mul_var(&c1, x); bvarith_buffer_normalize(&c1); test_buffer(&table, &c1); bvarith_buffer_prepare(&c1, 100); bvarith_buffer_add_var(&c1, z); bvarith_buffer_square(&c1); bvarith_buffer_mul_var(&c1, y); bvarith_buffer_mul_var(&c1, x); bvarith_buffer_normalize(&c1); test_buffer(&table, &c1); printf("=== Final table ===\n"); print_bvexp_table(stdout, &table); printf("\n"); // remove two variables bvexp_table_remove_vars(&table, 11); printf("=== After removing two variables ===\n"); print_bvexp_table(stdout, &table); printf("\n"); // recheck: 1 + x + y bvarith_buffer_prepare(&c1, 100); bvarith_buffer_set_one(&c1); bvarith_buffer_add_var(&c1, x); bvarith_buffer_add_var(&c1, y); bvarith_buffer_normalize(&c1); test_buffer(&table, &c1); // recheck: (x + z) * (y - z) bvarith_buffer_prepare(&c1, 100); bvarith_buffer_add_var(&c1, x); bvarith_buffer_add_var(&c1, z); bvarith_buffer_prepare(&c2, 100); bvarith_buffer_add_var(&c2, y); bvarith_buffer_sub_var(&c2, z); bvarith_buffer_mul_buffer(&c1, &c2); bvarith_buffer_normalize(&c1); test_buffer(&table, &c1); bvarith_buffer_prepare(&c1, 100); bvarith_buffer_add_var(&c1, x); bvarith_buffer_add_var(&c1, z); bvarith_buffer_prepare(&c2, 100); bvarith_buffer_add_var(&c2, y); bvarith_buffer_sub_var(&c2, z); bvarith_buffer_mul_buffer(&c1, &c2); bvarith_buffer_normalize(&c1); test_buffer(&table, &c1); printf("=== Final table ===\n"); print_bvexp_table(stdout, &table); printf("\n"); // cleanup delete_bvarith64_buffer(&b1); delete_bvarith64_buffer(&b2); delete_bvarith_buffer(&c1); delete_bvarith_buffer(&c2); delete_bvexp_table(&table); delete_bv_vartable(&vtbl); cleanup_bvconstants(); return 0; }