updated test to expect exceptions

This commit is contained in:
Brian Matzon 2005-05-12 15:44:22 +00:00
parent 0f5281e24f
commit c5c80aaa57
1 changed files with 30 additions and 31 deletions

View File

@ -99,18 +99,18 @@ public class SourceLimitTest extends BasicTest {
IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate); IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate);
//Create sourcesToCreate sources in one fell swoop //Create sourcesToCreate sources in one fell swoop
sources.position(0).limit(sourcesToCreate); try {
AL10.alGenSources(sources); sources.position(0).limit(sourcesToCreate);
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { AL10.alGenSources(sources);
System.out.println("failed to create " + sourcesToCreate + " sources (" + AL10.alGetString(lastError) + ")");
return; //delete sources
sources.position(0).limit(sourcesToCreate);
AL10.alDeleteSources(sources);
System.out.println("created " + sourcesToCreate + " sources successfully!");
} catch (OpenALException oale) {
System.out.println("Unable to create " + sourcesToCreate + " sources");
} }
//delete sources
sources.position(0).limit(sourcesToCreate);
AL10.alDeleteSources(sources);
System.out.println("created " + sourcesToCreate + " sources successfully!");
} }
/** /**
@ -123,34 +123,33 @@ public class SourceLimitTest extends BasicTest {
//make bytbuffer that can hold sourcesToCreate sources //make bytbuffer that can hold sourcesToCreate sources
IntBuffer[] sources = new IntBuffer[sourcesToCreate]; IntBuffer[] sources = new IntBuffer[sourcesToCreate];
//create the sources //create the sources
for (int i = 0; i < sourcesToCreate; i++) { try {
sources[i] = BufferUtils.createIntBuffer(1); for (int i = 0; i < sourcesToCreate; i++) {
sources[i].position(0).limit(1); sources[i] = BufferUtils.createIntBuffer(1);
AL10.alGenSources(sources[i]); sources[i].position(0).limit(1);
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) { AL10.alGenSources(sources[i]);
System.out.println("failed to create source: " + (i + 1)); if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
break; break;
}
sourcesCreated++;
} }
sourcesCreated++; } catch (OpenALException oale) {
System.out.println("failed to create source: " + (sourcesCreated + 1));
} }
//delete allocated sources //delete allocated sources
for (int i = 0; i < sourcesCreated; i++) { for (int i = 0; i < sourcesCreated; i++) {
//delete buffers and sources //delete buffers and sources
sources[i].position(0).limit(1); sources[i].position(0).limit(1);
AL10.alDeleteSources(sources[i]); AL10.alDeleteSources(sources[i]);
if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
System.out.println("failed to delete source: " + i + "(" + AL10.alGetString(lastError) + ")");
break;
}
} }
if(sourcesCreated != sourcesToCreate) { if(sourcesCreated != sourcesToCreate) {
System.out.println("created " + sourcesCreated + " sources before failing"); System.out.println("created " + sourcesCreated + " sources before failing");
} else { } else {
System.out.println("created " + sourcesCreated + " sources successfully!"); System.out.println("created " + sourcesCreated + " sources successfully!");
} }
} }
/** /**