TEST(Expression_Seq, seqInEqual) { int arr[] = { 1 }; TVP t = newSequence(1,arr); int arr2[] = { 2 }; TVP t2 = newSequence(1,arr2); TVP res = vdmSeqInEqual(t,t2); EXPECT_EQ(true, res->value.boolVal); recursiveFree(res); // recursiveFree(t); recursiveFree(t2); }
TEST(Expression_Seq, seqLen) { int arr[] = { 1, 2 }; TVP t = newSequence(2,arr); TVP res = vdmSeqLen(t); EXPECT_EQ(2, res->value.intVal); recursiveFree(res); // recursiveFree(t); }
TEST(Expression_Seq, seqConc) { int arr[] = { 1 }; TVP t = newSequence(1,arr); int arr2[] = { 2 }; TVP t2 = newSequence(1,arr2); TVP res = vdmSeqConc(t,t2); struct Collection* col = (struct Collection*) res->value.ptr; EXPECT_EQ(1, col->value[0]->value.intVal); EXPECT_EQ(2, col->value[1]->value.intVal); recursiveFree(res); // recursiveFree(t); recursiveFree(t2); }
TEST(Expression_Seq, seqTl) { int arr[] = { 1, 2 }; TVP t = newSequence(2,arr); TVP res = vdmSeqTl(t); struct Collection* col = (struct Collection*) res->value.ptr; EXPECT_EQ(2, col->value[0]->value.intVal); recursiveFree(res); // recursiveFree(t); }
TEST(Expression_Seq, seqIndex) { int arr[] = { 1, 2 }; TVP t = newSequence(2,arr); TVP index = newInt(2); TVP res = vdmSeqIndex(t,index); EXPECT_EQ(2, res->value.intVal); recursiveFree(res); // recursiveFree(t); recursiveFree(index); }
TEST(Expression_Seq, seqInds) { int arr[] = { 1, 2 }; TVP t = newSequence(2,arr); TVP res = vdmSeqInds(t); EXPECT_EQ(VDM_SET, res->type); struct Collection* col = (struct Collection*) res->value.ptr; EXPECT_TRUE(VDM_SET == res->type); //TODO this is actually not the VDM version of inds [1,2] = {1,2}, the second set and the set,set comp is missing, I didnt do sets yet EXPECT_TRUE(2 == col->value[0]->value.intVal || 2 == col->value[1]->value.intVal); EXPECT_TRUE(1 == col->value[0]->value.intVal || 1 == col->value[1]->value.intVal); recursiveFree(res); // recursiveFree(t); }
TEST(Expression_Seq, seqElems) { int arr[] = { 1, 2 }; TVP t = newSequence(2,arr); TVP a = newInt(1); TVP b = newInt(2); TVP elems = newSetVar(2, a,b); TVP res = vdmSeqElems(t); TVP tmp = vdmEquals(res,elems); EXPECT_EQ(true, tmp->value.boolVal); recursiveFree(res); vdmFree(a); vdmFree(b); vdmFree(tmp); vdmFree(elems); // recursiveFree(t); }
void FileGathererThread::gatheringKernel(const boost::shared_ptr<FileSystemItem>& item) { QDir dir( item->absoluteFilePath() ); Qt::SortOrder viewOrder = _imp->model->sortIndicatorOrder(); FileSystemModel::Sections sortSection = (FileSystemModel::Sections)_imp->model->sortIndicatorSection(); switch (sortSection) { case FileSystemModel::Name: dir.setSorting(QDir::Name); break; case FileSystemModel::Size: dir.setSorting(QDir::Size); break; case FileSystemModel::Type: dir.setSorting(QDir::Type); break; case FileSystemModel::DateModified: dir.setSorting(QDir::Time); break; default: break; } ///All entries in the directory QFileInfoList all = dir.entryInfoList(_imp->model->filter()); ///List of all possible file sequences in the directory or directories FileSequences sequences; int start; int end; switch (viewOrder) { case Qt::AscendingOrder: start = 0; end = all.size(); break; case Qt::DescendingOrder: start = all.size() - 1; end = -1; break; } int i = start; while (i != end) { ///If we must abort we do it now if ( _imp->checkForAbort() ) { return; } if ( all[i].isDir() ) { ///This is a directory sequences.push_back(std::make_pair(boost::shared_ptr<SequenceParsing::SequenceFromFiles>(), all[i])); } else { QString filename = all[i].fileName(); /// If the item does not match the filter regexp set by the user, discard it if ( !_imp->model->isAcceptedByRegexps(filename) ) { KERNEL_INCR(); continue; } /// If file sequence fetching is disabled, accept it if ( !_imp->model->isSequenceModeEnabled() ) { sequences.push_back(std::make_pair(boost::shared_ptr<SequenceParsing::SequenceFromFiles>(), all[i])); KERNEL_INCR(); continue; } std::string absoluteFilePath = generateChildAbsoluteName(item.get(), filename).toStdString(); bool foundMatchingSequence = false; /// If we reach here, this is a valid file and we need to determine if it belongs to another sequence or we need /// to create a new one SequenceParsing::FileNameContent fileContent(absoluteFilePath); ///Note that we use a reverse iterator because we have more chance to find a match in the last recently added entries for (FileSequences::reverse_iterator it = sequences.rbegin(); it != sequences.rend(); ++it) { if ( it->first && it->first->tryInsertFile(fileContent,false) ) { foundMatchingSequence = true; break; } } if (!foundMatchingSequence) { boost::shared_ptr<SequenceParsing::SequenceFromFiles> newSequence( new SequenceParsing::SequenceFromFiles(fileContent,true) ); sequences.push_back(std::make_pair(newSequence, all[i])); } } KERNEL_INCR(); } ///Now iterate through the sequences and create the children as necessary for (FileSequences::iterator it = sequences.begin(); it != sequences.end(); ++it) { item->addChild(it->first, it->second); } emit directoryLoaded( item->absoluteFilePath() ); }