Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- test('Only unmatched elements propose', function() {
- let traces = f(companies, candidates).trace;
- for (let k = 0; k < traces.length;++k) {
- for (let j = 0; j < k; ++j) {
- if (traces[k].from === traces[j].from && traces[k].fromCo && traces[j].fromCo) {
- let findReassignment = false;
- for (let r = j; j < k; ++j) {
- if (traces[j].to === traces[r].to && traces[r].fromCo && traces[j].fromCo) {
- findReassignment = true;
- }
- }
- if (!findReassignment) {
- assert(false);
- return;
- }
- }
- }
- }
- assert(true);
- });
- test('Traces do not contain invalid values (>= n)', function() {
- let traces = f(companies, candidates).trace;
- for (let k = 0;k < traces.length; ++k) {
- assert(traces[k].from < n);
- assert(traces[k].to < n);
- }
- });
- test('Out is the result of the trace (checking last)', function() {
- let functionOutput = f(companies, candidates);
- //console.log(functionOutput);
- let lastTrace = functionOutput.trace[functionOutput.trace.length-1];
- let companyMatch = 0;
- let candidateMatch = 0;
- if (lastTrace.fromCo) {
- companyMatch = lastTrace.from;
- candidateMatch = lastTrace.to;
- }
- else {
- companyMatch = lastTrace.to;
- candidateMatch = lastTrace.from;
- }
- //console.log(companyMatch);
- //console.log(candidateMatch);
- for (let k = 0; k < n; ++k) {
- if (functionOutput.out[k].company === companyMatch && functionOutput.out[k].candidate === candidateMatch) {
- assert(true);
- return;
- }
- }
- assert(false);
- });
- test('Check for duplicate traces', function() {
- let functionOutput = f(companies, candidates);
- let firstTrace = functionOutput.trace[0];
- let companyMatch = 0;
- let candidateMatch = 0;
- if (firstTrace.fromCo) {
- companyMatch = firstTrace.from;
- candidateMatch = firstTrace.to;
- }
- else {
- companyMatch = firstTrace.to;
- candidateMatch = firstTrace.from;
- }
- let containsMatch = false;
- for (let k = 0; k < n; ++k) {
- if (functionOutput.out[k].company === companyMatch && functionOutput.out[k].candidate === candidateMatch) {
- containsMatch = true;
- }
- }
- if (!containsMatch) {
- for (let k = 1; k < functionOutput.trace.length; ++k) {
- if (functionOutput.trace[k].from === companyMatch) {
- assert(true);
- return;
- }
- }
- assert(false);
- }
- else {
- assert(true);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment